webonnx/wonnx

Slice Operator

seddonm1 opened this issue · 2 comments

Currently the Onnx Slice operator is not implemented.

I have just started looking at the WGSL code and may be able to work this out slowly but wanted to know if there is anything that is required before being able to implement the operator?

Hi! The Slice operator should be fairly straightforward to implement - I suggest you to take a look at the implementation of e.g. the Gather op which is a bit more complicated (or e.g. Softmax to see how to deal with the axis logic). Basically, you would first calculate the size of the output, then write a shader that (for each element of the output, but chunked for efficiency) copies the relevant elements from the source to the output vector.

For implementing a new op, simply follow the instructions in the README.

I will be happy to assist you and review a PR. We do require contributions to be licensed "MIT OR Apache-2.0" and before merging I would also like to see a test for the op included (as well as the relevant ONNX backend op tests enabled).

Note that shape inference for Slice is already implemented here so that's one thing you don't have to worry about anymore :-)

Thanks @pixelspark .

I will see what I can work out having only very limited exposure to compute shaders.