File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
python/tvm/relay/backend/contrib/ethosu/te Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 2121
2222def get_layout_transform_matrices (ofm_channels : int ) -> Tuple [List [List [float ]], List [List [float ]]]:
2323 """Get the NHWC->NHCWB16 and NHCWB16->NHWC layout transform matrices.
24+ For information about the supported layouts see https://developer.arm.com/documentation/102420/
25+ 0200/Functional-description/Control-and-data-flow/Supported-memory-formats-for-feature-maps
2426
2527 Parameters
2628 ----------
@@ -33,6 +35,7 @@ def get_layout_transform_matrices(ofm_channels: int) -> Tuple[List[List[float]],
3335 The layout transformation matrices
3436 """
3537
38+ # The value of the last dimension (B16) is always 16.
3639 nhwc_to_nhcwb16 = [
3740 [1 , 0 , 0 , 0 , 0 ],
3841 [0 , 1 , 0 , 0 , 0 ],
@@ -42,6 +45,10 @@ def get_layout_transform_matrices(ofm_channels: int) -> Tuple[List[List[float]],
4245 [0 , 0 , 0 , 0 , 1 ],
4346 ]
4447
48+ # When we convert from NHWC to NHCWB16, the new C value is given by
49+ # (ofm_channels - 1) // 16 + 1, which is a lossy operation, so we need to use
50+ # the actual value of channels in the transform matrix to accurately recover
51+ # the C in NHWC when we convert from NHCWB16 to NHWC.
4552 nhcwb16_to_nhwc = [
4653 [1 , 0 , 0 , 0 , 0 , 0 ],
4754 [0 , 1 , 0 , 0 , 0 , 0 ],
You can’t perform that action at this time.
0 commit comments