qonnx icon indicating copy to clipboard operation
qonnx copied to clipboard

[MultiThreshold] Generalize data layouts for node execution

Open iksnagreb opened this issue 1 year ago • 1 comments

The relevant aspect of the data layout annotation seems to be which axis is labeled as the channel dimension "C": We do not actually have to care about the total number and ordering of the other axes, as long as we can find the index of the "C" axis and swap to have "C" at index 1 for node execution (and swap it back afterwards).

Falls back to the default assumption that "C" is at index 1 if there is no layout annotation, which is equivalent to the "NCHW" or "NC" layouts.

This is a rather experimental change which might break existing code and is currently still restricted to the well-known 2-, 3- and 4-dimensional layouts.

This PR is based on #92 which is less experimental and should be merged first (#92 also does not risk breaking existing code as it only adds new special cases).

iksnagreb avatar Sep 13 '24 13:09 iksnagreb

Instead of relying on data layout strings, how about we switch to an attribute axis (like many standard ONNX ops do) to indicate the location (index) of the channels axis? I'd actually prefer to deprecate the old data_layout attribute, and I think we can still keep backwards compatibility by treating data_layout=NCHW as axis=1 and data_layout=NHWC as axis=-1. If the interpretation of the two attributes disagree, the axis one can dominate.

maltanar avatar Dec 17 '24 13:12 maltanar