Best way to deal with kernel layout?

@jinchenglee thanks for asking this question, I’m facing a similar issue

@comaniac I was not aware of this data layout transformation process. It would be useful for me as well, as I’m targetting a microcontroller with embedded accelerator, which has a very specific data layout. I’m not using BYOC though (our approach is covered in this recent post). I thought I would have to make separate operator implementations with data layout preparation steps for each operator from the Relay Strategy. Like here (ARM seems to have different TOPI operators for different data layouts, but this seems opposite to your answer above):

I find it a bit confusing that it is apparently possible to account for different data layouts in different parts of the stack.

Also I find it a bit weird that this data layout pass would be implemented as a relay pass, as I thought relay passes are supposed to be hardware independent. But actually I don’t think such a data transformation pass would be useful for other devices that don’t expect the same data layout as the accelerator, so that would need to be hardware dependent then, right?

How do you think I should proceed? Is your answer different if we don’t use BYOC? And is there some documentation on data layout transformations along the TVM stack perhaps, besides the example you showed us? Thanks!

1 Like