microsoft / antares

Antares: an automatic engine for multi-platform kernel generation and optimization. Supporting CPU, CUDA, ROCm, DirectX12, GraphCore, SYCL for CPU/GPU, OpenCL for AMD/NVIDIA, Android CPU/GPU backends.
Other
435 stars 45 forks source link

[Help Request] How can Antares IR support stride size > 1 's Slice operation? #354

Closed LeiWang1999 closed 2 years ago

LeiWang1999 commented 2 years ago

Currently we got an issue when we use antares to tune a swin-transformer model, it has a slice operation which's steps can be larger that one.

But from the AntaresIR.md, we noticed that the ir can only support step size equal to 1, for a onnx model I made for antares slice operation test, which same to the onnx operation documentation :

image

If the steps' data is [1, 1], we can simply get the antares ir code :

output0[N0, N1] = input0[N0 + 1, N1 + 0] where N0 in 1 , N1 in 3

but if the steps' data is [1, 2], it's hard to describe the compute logic :

output0[N0, N1] = input0[N0 + 1, N1 + 0] where N0 in 1 , N1 in {0, 2}

the N1 should jump over the index 2, but I don't find the way to come up with this idea.

So please any suggestion for this case?

LeiWang1999 commented 2 years ago

Please CC @ghostplant , Thanks

ghostplant commented 2 years ago

Do you mean output0[N0, N1] = input0[N0 + 1, N1 * {step} + {start}] where N0 in 1 , N1 in { ceil((end - start) / step) }

LeiWang1999 commented 2 years ago

LGTM, Thanks a lot! @ghostplant