Skip to content

Commit

Permalink
[microTVM] Update support for ARMv7m intrinsic (#8990)
Browse files Browse the repository at this point in the history
* [microTVM] Update support for ARMv7m intrinsic

 - Improved implementaion of gemm function for conv2d
 - Removed %4 restriction for channels
 - Added test case to verify SMLAD intrinsic speed acceleration

Signed-off-by: Sergey Smirnov <Sergey@grovety.com>

* [microTVM] Update support for ARMv7m intrinsic

 - Improved implementaion of gemm function for conv2d
 - Removed %4 restriction for channels
 - Added test case to verify SMLAD intrinsic speed acceleration

Signed-off-by: Sergey Smirnov <Sergey@grovety.com>

* Implemented discussed changes.

* Removed unnecessary test files.

* Formatting fixed.

* Formatting fixed2.

* Formatting fixed3.

* Formatting fixed4.

* Formatting fixed5.

* Fixed test time result checking.

* Check rebuild.

* Formatting fixed.

* Formatting fixed.

* [microTVM] Update support for ARMv7m intrinsic

 - Improved implementaion of gemm function for conv2d
 - Removed %4 restriction for channels
 - Added test case to verify SMLAD intrinsic speed acceleration

Signed-off-by: Sergey Smirnov <Sergey@grovety.com>

* Implemented discussed changes.

* Removed unnecessary test files.

* Formatting fixed.

* Formatting fixed2.

* Formatting fixed3.

* Formatting fixed4.

* Formatting fixed5.

* Fixed test time result checking.

* Check rebuild.

* Formatting fixed.

* Issue 8717 Add schedule for depthwise_conv2d_nhwc

* Resolve merge conflict.

* Resolve merge conflicts.

* Fixed formatting.

* From Issue 8717//
Fixed micro model library test. Checking size reduced to 16 bytes from 2466816.

* From Issue 8717.
Removed changes.

* From Issue 8717. Fixed typo.

* Fixed import.

* Fixed import and method call.

* Added QEMU testing comment.

* Fixed ZEPHYR_BOARD usage.

* Fixed tests. Removed issue 8717 changes.

* Formatting fixed.

* Removed test call from base_box_test.sh
  • Loading branch information
sergio-grovety authored Sep 30, 2021
1 parent 12330ca commit c51f429
Show file tree
Hide file tree
Showing 6 changed files with 679 additions and 119 deletions.
3 changes: 1 addition & 2 deletions python/tvm/relay/op/strategy/arm_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ def conv2d_strategy_arm_cpu(attrs, inputs, out_type, target):
name="conv2d_hwcn.generic",
)
elif layout == "NHWC":
channels = data.shape[3]
if "SMLAD" in isa and (channels % 4) == 0 and kernel_layout == "HWOI":
if "SMLAD" in isa and kernel_layout == "HWOI":
strategy.add_implementation(
wrap_compute_conv2d(topi.arm_cpu.conv2d_direct_simd),
wrap_topi_schedule(topi.arm_cpu.schedule_conv2d_direct_simd),
Expand Down
13 changes: 11 additions & 2 deletions python/tvm/topi/arm_cpu/cortex_m7/conv2d/direct_simd.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,14 @@ def conv2d_direct_simd_compute(cfg, data, kernel, strides, padding, dilation, ou
cfg.reduce_axis(in_channels.value),
)

assert in_channels.value % 4 == 0
owo, owi = cfg.define_split("tile_ow", ow, policy="factors", num_outputs=2)
cio, cii = cfg.define_split(
"tile_ci", ci, policy="factors", num_outputs=2, filter=lambda x: x.size[-1] % 4 == 0
"tile_ci",
ci,
policy="factors",
num_outputs=2,
# TODO: check case with in_channels.value % 4 != 0 with AutoTVM
filter=None if cfg.is_fallback else lambda x: x.size[-1] % 4 == 0,
)
coo, coi = cfg.define_split("tile_co", co, policy="factors", num_outputs=2)

Expand All @@ -134,6 +138,11 @@ def conv2d_direct_simd_compute(cfg, data, kernel, strides, padding, dilation, ou
cfg.define_knob("auto_unroll_max_step", [0, 2, 4, 8, 16, 32])
cfg.define_knob("unroll_explicit", [0, 1])

if cfg.is_fallback:
cfg.fallback_split("tile_ow", [-1, out_width.value])
cfg.fallback_split("tile_ci", [-1, in_channels.value])
cfg.fallback_split("tile_co", [-1, out_channels.value])

return conv


Expand Down
Loading

0 comments on commit c51f429

Please sign in to comment.