MIOpen icon indicating copy to clipboard operation
MIOpen copied to clipboard

[DRAFT] Fix op tensor nhwc

Open atamazov opened this issue 1 year ago • 3 comments

WIP for #2860

atamazov avatar Aug 09 '24 21:08 atamazov

@CAHEK7 @averinevg For early preview

atamazov avatar Aug 09 '24 21:08 atamazov

Tensor operations are layout agnostic, the most important limitation is all the tensors must have the same layout. Another limitation from the current implementation - all the kernels, even the generic one, do not support strides in the last dimension, so even if the layout is not default, but the last dimension is tightly packed, we can use most of the kernels (in the other words, we must check that the last dimension stride is 1 and skip any layout checks). Or if the layout is transposed using strides, we should rearrange lengths and strides for all the tensors to make tightly packed dimension the last. Layout information is required only for keeping all the tensors in the same layout.

Technically we even can omit this check if(lay_a != lay_b) if we can normalize tensor B layout and still have the last non-singular dimension's stride equals to 1. For example, for NCHW tensor A we can apply any NXXX tensor B if it has the following dimensions: N111. Because there is only 1 scalar value applied to the whole CHW instance.

CAHEK7 avatar Aug 13 '24 13:08 CAHEK7

🛠️ Detection of "mismatched tensor layouts" cannot help to resolve the problem. The PR will be reworked.

atamazov avatar Sep 16 '24 20:09 atamazov

This PR decided to be closed, because there is another approach to fix that problem.

CAHEK7 avatar Oct 09 '24 14:10 CAHEK7