Skip to content
Merged
Show file tree
Hide file tree
Changes from 169 commits
Commits
Show all changes
177 commits
Select commit Hold shift + click to select a range
ee5c4bf
Added scripts to run simple model
Aug 23, 2021
6800b8d
moved common functions to separate file
Aug 25, 2021
30169d0
added convinient funcs for working with models
Aug 26, 2021
a34ddcb
fixed AOT & project template to grovety folder
Aug 27, 2021
5560645
added conv2d test: using of tensorflow and merging of results
Aug 28, 2021
3fe5aa8
Added new interface to the MCU firmware (AOT)
Aug 31, 2021
ae4d9e3
added mnist model skeleton
Aug 31, 2021
5049d86
Fixed opening model for sine_zephyr
Aug 31, 2021
0e24218
Addedd mnist model
Aug 31, 2021
407b8ff
Added full support for mnist model
Sep 1, 2021
f853977
model conversion hack added
Sep 1, 2021
ae4c851
Arm7m C code optimization integrated. Removed %4 requirement for chan…
Sep 1, 2021
0493721
Merge remote-tracking branch 'mir/PRJ1445-1-conv2d' into grovety
Sep 2, 2021
a892bca
added support for quantized model
Sep 3, 2021
d1a33e0
Update gemm intrinsic (python\tvm\topi\arm_cpu\cortex_m7\micro_kernel…
GermanTretiakov Sep 7, 2021
ecf7bb2
Fix for qnn.conv2d legalized to int16
Sep 7, 2021
0ceb612
Switch between gemm8 and gemm16.
GermanTretiakov Sep 7, 2021
5f257ca
Merge remote-tracking branch 'mir/Auto_gemm8_gemm16' into PRJ1445-3-a…
Sep 7, 2021
4e8f56e
Format fixes, restores asserts for SMLAD usage
Sep 7, 2021
34b1b6f
Added CIFAR10 model
Sep 7, 2021
a81bf16
Great refactoring. All the modeles structured to run in the same way
Sep 7, 2021
32364a7
Try to remove arm_math.h and arm_nnsupportfunctions.h files from C code.
GermanTretiakov Sep 7, 2021
820969c
Fix: double {{ and }}
GermanTretiakov Sep 7, 2021
e6ac0d7
Add max_pool intrinsic (only C code).
GermanTretiakov Sep 8, 2021
dce7874
Merge remote-tracking branch 'mir/Auto_gemm8_gemm16' into grovety
Sep 8, 2021
4327ce2
Add relu intrinsic (only C code).
GermanTretiakov Sep 8, 2021
176d2c4
added { } to follow codestyle
Sep 9, 2021
c19d943
Added intrinsics enabling depending on the target
Sep 9, 2021
1860689
removed useless int8-int16 conversion
Sep 9, 2021
0f01b71
added disable optimization flag
Sep 9, 2021
6dc7e11
Merge remote-tracking branch 'mir/Auto_gemm8_gemm16' into grovety
Sep 9, 2021
c1c9f97
Fix: gemm16 update (mistyped with body).
GermanTretiakov Sep 9, 2021
4f8ab09
Added dataset for cifar10
Sep 9, 2021
25156b0
Merge remote-tracking branch 'mir/gemm_fixed' into grovety
Sep 9, 2021
0f68a39
Added data conversion to CIFAR10
Sep 9, 2021
a73df72
Small refactoring.
GermanTretiakov Sep 9, 2021
f4a4d82
Small fix: gemm_reset
GermanTretiakov Sep 9, 2021
aeef970
Merge remote-tracking branch 'mir/gemm_fixed' into grovety
Sep 9, 2021
47a0711
[PRJ1445-PR1-candidate] First upload.
Sep 9, 2021
02ff764
[PRJ1445-PR1-candidate] Fixed gemm.py. Again.
Sep 9, 2021
1ebe1d8
Updated test for different targets, Added missing deps
Sep 10, 2021
9196909
[PRJ1445-PR1-candidate] Fix test model.
Sep 10, 2021
690dd17
Removed check for in_channels % 4 for conv2d_direct_simd
Sep 10, 2021
aea91dd
Added ARM v7m test case to microTVM reference-VM base_box_test.sh
Sep 10, 2021
5f8f587
Schedule for max_pool2d for arm_cpu
Sep 10, 2021
b4b01d4
max_pool intrinsic (not tested at all).
GermanTretiakov Sep 10, 2021
fcbe0a3
Merge remote-tracking branch 'mir/PR1445-PR1-candidate' into grovety
Sep 10, 2021
3212f44
added --skip-flash flag to grovety script
Sep 10, 2021
e7da13e
Merge remote-tracking branch 'mir/grovety' into PRJ1445-3-arm-schedules
Sep 11, 2021
5351360
Types and checks for max_pool intrin, added pragma
Sep 11, 2021
83e254d
Moved intrinsics for max to micro_kernel dir
Sep 11, 2021
1b03c68
Fix: typo
GermanTretiakov Sep 11, 2021
c97fcf3
Try to measure operations cost.
GermanTretiakov Sep 11, 2021
facd7df
small refactoring of max_pool stuff
Sep 12, 2021
49976a2
Add calls of timer in gemm .
GermanTretiakov Sep 12, 2021
f1ebae9
layout conversion is made by default now
Sep 12, 2021
2abea65
Added grovety performance timer
Sep 12, 2021
f044427
Dense schedule for arm_cpu
Sep 12, 2021
500ef88
Add dense default strategy for arm_cpu
Sep 12, 2021
4617429
Fix: put extern "C" under #ifdef
GermanTretiakov Sep 12, 2021
b094dbf
fixed tiny typos
Sep 12, 2021
795c1e2
added perf timer
Sep 12, 2021
e911e5c
Merge remote-tracking branch 'mir/fix_gemm_timer' into grovety
Sep 12, 2021
8a05a55
Merge remote-tracking branch 'mir/dense-schedule' into grovety
Sep 12, 2021
86f4906
Added per-op benchmarking
Sep 12, 2021
be1aa86
Finally added a proper parsing of the march parameter of 'target' string
Sep 12, 2021
414b431
Update: max_pool can work with unaligned pointers (not tested at all).
GermanTretiakov Sep 13, 2021
ed695fd
avg_pool draft
Sep 12, 2021
fc5556a
fixes for intrinsic and tensorization pattern
Sep 14, 2021
4023481
fixes after rebase, removed SMUAD from isa
Sep 14, 2021
3dd6cb8
Added a hack to enable -O3 optimization
Sep 15, 2021
2f99b9e
Merge branch 'optimization' into grovety
Sep 15, 2021
a26c811
Merge remote-tracking branch 'mir/unaligned_max_pool' into grovety
Sep 15, 2021
dad1cbd
Merge remote-tracking branch 'mir/avg-pool-2d' into grovety
Sep 15, 2021
5fcec5e
Add MaxPool1d schedule
Sep 14, 2021
2ef763f
Merge remote-tracking branch 'mir/MaxPool1d' into grovety
Sep 15, 2021
a1794c3
Try to remove CMSIS headers from gemm functions.
GermanTretiakov Sep 15, 2021
750f0e3
Move system declarations into cortex_m7_defines.h to prevent duplicat…
GermanTretiakov Sep 15, 2021
1fb5e14
Add: __asm, stdint.h
GermanTretiakov Sep 15, 2021
b28719e
Add schedule for depthwise_conv2d_nhwc
Sep 15, 2021
e442e11
cortex defines moved
Sep 16, 2021
9e186ab
Add __SSUB8, __SEL .
GermanTretiakov Sep 16, 2021
38c05e9
Merge remote-tracking branch 'mir/8717-x86-DwsConv2d-schedule' into g…
Sep 16, 2021
d69b725
removed all references to CMSIS
Sep 16, 2021
5531f6b
Merge remote-tracking branch 'mir/no_cmsis_headers' into grovety
Sep 16, 2021
4181a73
Add annotation for schedule_depthwise_conv2d_nhwc
Sep 16, 2021
327179f
Add AvgPool1d schedule
Sep 16, 2021
caa3f66
Merge remote-tracking branch 'mir/8717-x86-DwsConv2d-schedule' into g…
Sep 17, 2021
c12fb05
Merge remote-tracking branch 'mir/avg-pool-1d' into grovety
Sep 17, 2021
b024a1a
added cifar10_2 data
Sep 15, 2021
6908a95
relay reading update
Sep 15, 2021
7b50e1d
Fixed data preparation to send to network
Sep 16, 2021
5755f17
all the models moved to specific folder
Sep 17, 2021
2e71d7a
Added custom include for M7 (no CMSIS)
Sep 20, 2021
e333d0e
Added networks for avg/max pool 1d
Sep 20, 2021
daf4743
new version of the Andrew's demo model
Sep 20, 2021
4d73775
template for running model on the CPU (for result comparing)
Sep 20, 2021
dd0c0df
Merge branch 'cifar10_from_relay' into grovety
Sep 20, 2021
0854f40
first version (not working)
Sep 20, 2021
080a7a9
fix conv1d
Sep 21, 2021
748d1a6
fix axis order for conv1d
Sep 21, 2021
c198db9
Added support of M33
Sep 21, 2021
74d693f
Added avg_pool 2D test
Sep 21, 2021
f4f410f
Conv1d implementation similar to conv2d with autotvm
Sep 21, 2021
1640f0f
Check for unsupported layout
Sep 21, 2021
68cfdb3
Merge remote-tracking branch 'mir/conv1d' into grovety
Sep 21, 2021
66bcec9
Check for WOI kernel layout
Sep 22, 2021
c2698c8
Fixed conv naming issue during import
Sep 22, 2021
5d1e0d2
Added additional types for input/output
Sep 22, 2021
4cfcad0
more synth models for tests
Sep 22, 2021
8307915
Merge remote-tracking branch 'mir/conv1d' into grovety
Sep 22, 2021
7620afc
use x86 depthwise_conv2d_nhwc schedule for arm_cpu
Sep 22, 2021
f29b131
Check and show warning for unsupported types for pooling
Sep 23, 2021
647e3ff
Renaming for maxpool micro-kernel
Sep 23, 2021
64efb87
Add x86 schedule for depthwise_conv2d_nhwc
Sep 23, 2021
a7adf41
use x86 depthwise_conv2d_nhwc schedule for arm_cpu
Sep 22, 2021
37d3c81
added assert for unaligned pointers in the gemm16
Sep 24, 2021
a6c4e07
Expanding stack to 4k
Sep 24, 2021
5963b4b
Merge branch 'branch' into grovety
Sep 24, 2021
7a6217c
Merge remote-tracking branch 'mir/pool-type-check' into grovety
Sep 24, 2021
eafab3e
Merge remote-tracking branch 'mir/issue8717' into grovety
Sep 24, 2021
0482186
Merge remote-tracking branch 'mir/8717-x86-DwsConv2d-schedule' into g…
Sep 24, 2021
32ede71
fix test_export_model_library_format_workspace
Sep 24, 2021
4398d5f
Fix for max_pool8 micro-kernel renaming
Sep 24, 2021
fd657b9
Added complex test
Sep 24, 2021
8f036c3
Merge remote-tracking branch 'mir/fix-max-pool-kernel-naming' into gr…
Sep 24, 2021
2811f99
Added SIMD disabling flag to complex test
Sep 24, 2021
0b1c836
Merge remote-tracking branch 'mir/issue8717' into grovety
Sep 27, 2021
c18164a
move schedule_depthwise_conv2d_nhwc to generic conv2d, add test for s…
Sep 28, 2021
950c5ea
fix format
Sep 28, 2021
ab6f111
Revert "fix test_export_model_library_format_workspace"
Sep 28, 2021
a52e09e
fix format in test_topi_depthwise_conv2d.py
Sep 29, 2021
1190245
Merge remote-tracking branch 'mir/issue8717' into grovety
Oct 1, 2021
f015b88
Merge remote-tracking branch 'origin/main' into grovety
Oct 1, 2021
5aaba80
initial simd test commit
Oct 1, 2021
3e80c0c
Do not run corstone integration tests for GPU-only mode
Oct 1, 2021
73569f2
Added @tvm.testing.requires_corstone300 decorator
Oct 1, 2021
38f6c5a
Added corstone300 marker processing
Oct 4, 2021
66a4587
Added target opts to aot_test... compiation process
Oct 5, 2021
3c4e2e2
Removed unused code from M7 micro_kernel generation
Oct 6, 2021
766db57
Added target_opts parameter instead of separate param for every option
Oct 6, 2021
71d8ff6
Added common defines for m7 simd
Oct 6, 2021
b7dc932
Added missing types for aot input data codegen
Oct 6, 2021
977559b
Tests added
Oct 6, 2021
6986fe1
removed "strange" code
Oct 6, 2021
cab48e7
tests fixed
Oct 7, 2021
7acbb63
Merge remote-tracking branch 'mir/corstone-tests' into cortex-m7-intr…
Oct 7, 2021
a52a48a
avg_pool micro kernel bugfix
Oct 7, 2021
771ae0d
tests fixed
Oct 7, 2021
feacab6
Fix for intrin_sum accumulator reset for avgpool_1d
Oct 8, 2021
9270261
Removed unused target options
Oct 8, 2021
6a0c573
Added --corstone300 parameter to enable simd tests
Oct 8, 2021
7006824
Added more m7 test cases, fixed cmsisnn includes
Oct 8, 2021
0f4e1ea
Added ASL header to fix lint check
Oct 11, 2021
cba97aa
renamed --corstone300 to --enable-corstone300-tests
Oct 11, 2021
a99440b
Fixed lint warnings
Oct 11, 2021
c082335
Added missing chech for None
Oct 11, 2021
94c8f3a
This file appeared here by mistake. relu SIMD implementation is not r…
Oct 11, 2021
3e54254
add a layout name for conv1d functions
Oct 13, 2021
cc42c4d
add cases for test_conv2d
Oct 13, 2021
66dbd5d
bugfix for the issue https://github.com/apache/tvm/issues/9226
Oct 14, 2021
638846a
fixed conv2d naming
Oct 14, 2021
4de1c16
minor changes according Andrew's comments
Oct 15, 2021
3c81bea
minor changes according Andrew's comments
Oct 15, 2021
388b62a
fix conv2d names
Oct 15, 2021
53c847c
return code instead of assert in gemm.py
Oct 15, 2021
3d577ca
change check for avg_pool
Oct 18, 2021
9c403fe
Merge branch 'PR2-preview' into cortex-m7-intrinsic
Oct 18, 2021
fb17329
Renaming of "Cortex-M7 SIMD" in commens to DSP
ilyag-grovety Oct 27, 2021
4803e19
Merge branch 'main' into cortex-m7-intrinsic
ilyag-grovety Oct 28, 2021
975aff4
Merge remote-tracking branch 'origin/main' into cortex-m7-intrinsic
Nov 1, 2021
6cec82c
Disable corstone tests for i386 run
Nov 1, 2021
a593538
Merge remote-tracking branch 'origin/main' into cortex-m7-intrinsic
Nov 2, 2021
bc2b4ec
methods renamed direct_simd -> dsp
Nov 9, 2021
be7078a
Fixed linter warnings
Nov 9, 2021
9d25cf6
Fixed test name
Nov 9, 2021
1407614
Merge commit '74accec52e41418d796b6699991c9136993b129e' into cortex-m…
Nov 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 88 additions & 4 deletions python/tvm/relay/op/strategy/arm_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import re
import logging

from tvm import topi
from tvm import relay, topi
from ....target import arm_isa
from ....topi.generic import conv2d as conv2d_generic
from .generic import *
Expand Down Expand Up @@ -49,6 +49,26 @@ def schedule_concatenate_arm_cpu(_, outs, target):
return topi.arm_cpu.schedule_concatenate(outs)


@schedule_pool.register(["arm_cpu"])
def schedule_pool_arm_cpu(attrs, outs, target):
"""schedule pooling ops arm cpu"""
layout = attrs.layout
isa = arm_isa.IsaAnalyzer(target)
avg_pool = isinstance(attrs, relay.op.op_attrs.AvgPool2DAttrs)
with target:
if (
avg_pool
and layout in ("NCW", "NCHW")
and "SMLAD" in isa
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SMLAD, SSUB8 and SEL are part of the DSP instructions and the presence of one implies the presence of the other. I also think that in this case since we are adding all of these together globbing them into a single check for the use of the DSP extensions should be sufficient. Any reason why we are testing individual instructions ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree with you that we should refactor this. this was left over from the initial implementation which did propose to test for presence of instructions in the ISA; however, you're right that we should just need to determine which architecture is in use. since this PR just adds additional schedules which are purported to be compatible with cortex-m7 devices, perhaps we can address the question of lookup-by-architecture in a follow-on.

or not avg_pool
and "SSUB8" in isa
and "SEL" in isa
and layout in ("NWC", "NHWC")
):
return topi.arm_cpu.schedule_pool(outs, layout)
return topi.generic.schedule_pool(outs, layout)


@conv2d_strategy.register(["arm_cpu", "micro_dev"])
def conv2d_strategy_arm_cpu(attrs, inputs, out_type, target):
"""conv2d arm cpu strategy"""
Expand Down Expand Up @@ -130,9 +150,9 @@ def conv2d_strategy_arm_cpu(attrs, inputs, out_type, target):
elif layout == "NHWC":
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),
name="conv2d_direct_simd.micro_dev",
wrap_compute_conv2d(topi.arm_cpu.conv2d_nhwc_direct_simd),
wrap_topi_schedule(topi.arm_cpu.schedule_conv2d_nhwc_direct_simd),
name="conv2d_nhwc_direct_simd.micro_dev",
)
elif kernel_layout == "HWIO":
is_aarch64 = topi.arm_cpu.arm_utils.is_aarch64_arm()
Expand Down Expand Up @@ -415,3 +435,67 @@ def schedule_bitserial_dense_arm_cpu(attrs, inputs, out_type, target):
name="bitserial_dense.arm_cpu",
)
return strategy


@dense_strategy.register(["arm_cpu"])
def schedule_dense_arm_cpu(attrs, inputs, out_type, target):
"""dense arm cpu strategy"""
strategy = _op.OpStrategy()
isa = arm_isa.IsaAnalyzer(target)
if "SMLAD" in isa:
strategy.add_implementation(
wrap_compute_dense(topi.nn.dense),
wrap_topi_schedule(topi.arm_cpu.schedule_dense_direct_simd),
name="dense_direct_simd",
)
else:
strategy.add_implementation(
wrap_compute_dense(topi.nn.dense),
wrap_topi_schedule(topi.generic.schedule_dense),
name="dense.generic",
)
return strategy


@conv1d_strategy.register("arm_cpu")
def conv1d_strategy_arm_cpu(attrs, inputs, out_type, target):
"""conv1d strategy"""
strategy = _op.OpStrategy()
layout = attrs.data_layout
kernel_layout = attrs.kernel_layout
dilation = get_const_tuple(attrs.dilation)
if dilation[0] < 1:
raise ValueError("dilation should be a positive value")

isa = arm_isa.IsaAnalyzer(target)

if kernel_layout == "WOI":
if layout == "NWC" and "SMLAD" in isa:
strategy.add_implementation(
wrap_compute_conv1d(topi.arm_cpu.conv1d_nwc_direct_simd),
wrap_topi_schedule(topi.arm_cpu.schedule_conv1d_nwc_direct_simd),
name="conv1d_direct_simd",
)
else:
raise RuntimeError(
"Unsupported kernel layout {} for conv1d {} for arm cpu.".format(
kernel_layout, layout
)
)
elif layout == "NCW":
strategy.add_implementation(
wrap_compute_conv1d(topi.nn.conv1d_ncw),
wrap_topi_schedule(topi.generic.schedule_conv1d_ncw),
name="conv1d_ncw.generic",
)
elif layout == "NWC":
strategy.add_implementation(
wrap_compute_conv1d(topi.nn.conv1d_nwc),
wrap_topi_schedule(topi.generic.schedule_conv1d_nwc),
name="conv1d_nwc.generic",
)
else:
raise RuntimeError(
"Unsupported kernel layout {} for conv1d {} for arm cpu.".format(kernel_layout, layout)
)
return strategy
2 changes: 2 additions & 0 deletions python/tvm/relay/qnn/op/legalizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ def _qnn_conv2d_legalize_arm_cpu(attrs, inputs, types):
attrs["kernel_layout"],
attrs["groups"],
)

# Use int8 for Cortex-M7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not limited to this CPU?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sergey-grovety can you revert this comment or fix the set of CPUs indicated?

use_int8_on_arm = (not is_depthwise) and is_aarch64_arm() and attrs["data_layout"] == "NHWC"
if use_int8_on_arm or is_fast_int8_on_arm():
return helper_change_dtypes_to_be_same(attrs, inputs, types, relay.qnn.op.conv2d)
Expand Down
14 changes: 10 additions & 4 deletions python/tvm/target/arm_isa.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,24 @@
# under the License.
"""Defines functions to analyze available opcodes in the ARM ISA."""

import argparse

ARM_ISA_MAP = {
"armv7e-m": ["SMLAD"],
"armv7e-m": ["SMLAD", "SSUB8", "SEL"],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

armv7e-m : DSP ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@u99127 as discussed, let's punt the architecture labelling to the next PR.

"armv8-m": ["SMLAD", "SSUB8", "SEL"],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what you want is armv8-m.main.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing here

}


class IsaAnalyzer(object):
"""Checks ISA support for given target"""

def __init__(self, target):
self.target = target
# TODO: actually parse -mcpu
arch = "armv7e-m"
self._isa_map = ARM_ISA_MAP[arch]
parser = argparse.ArgumentParser()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for this one it should be possible to grab from target["mcpu"]. could you try this and see if it works rather than relying on argparse?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if I understand you correctly, but target here is a string

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should use the built-in Target parsing logic here rather than argparse:

Suggested change
parser = argparse.ArgumentParser()
target = tvm.target.Target(target)
march = target.attrs.get("-march", None)
self._isa_map = ARM_ISA_MAP[march] if march is not None else []

(also need to delete the following lines 33-36--suggestion didn't quite get the diff)

parser.add_argument("-mcpu", type=str)
parser.add_argument("-march", type=str)
args, _ = parser.parse_known_args(str(target).split())
self._isa_map = ARM_ISA_MAP[args.march] if args.march in ARM_ISA_MAP else []

def __contains__(self, instruction):
return instruction in self._isa_map
1 change: 1 addition & 0 deletions python/tvm/testing/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"llvm": "mark a test as requiring llvm",
"ethosn": "mark a test as requiring ethosn",
"hexagon": "mark a test as requiring hexagon",
"corstone300": "mark a test as requiring Corstone300 FVP",
}


Expand Down
12 changes: 12 additions & 0 deletions python/tvm/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,18 @@ def requires_opencl(*args):
return _compose(args, _requires_opencl)


def requires_corstone300(*args):
"""Mark a test as requiring the corstone300 FVP

Parameters
----------
f : function
Function to mark
"""
_requires_corstone300 = [pytest.mark.corstone300]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it also needs a skipif() in here. mark is on-by-default iiuc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm adding a pytest.marker.skip() to the tests marked requires_corstone300 in the tests/python/conftest.py depending on the value of the "--enable-corstone300-tests" flag. Haven't found a better way to control tests behavior since we don't have device_enabled() for corstone300

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a better way of controlling this - possibly something @Mousius could comment on here ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i discussed this with @grant-arm a bit and it seems the consensus was that there isn't a good way to auto-detect the FVP. perhaps we've missed something though?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on how these tests are ran, we could use the slightly icky AOT skip logic:

skip_i386 = pytest.mark.skipif(
platform.machine() == "i686", reason="Reference system unavailable in i386 container"
)
requires_arm_eabi = pytest.mark.skipif(
shutil.which("arm-none-eabi-gcc") is None, reason="ARM embedded toolchain unavailable"
)

This would at least automate it if these tests are designed to run in CPU containers. Otherwise, we should just be able to check for the path since we know exactly where we're checking it out in the container:

fvp_dir="/opt/arm/FVP_Corstone_SSE-300_Ethos-U55"

return _compose(args, _requires_corstone300)


def requires_rocm(*args):
"""Mark a test as requiring the rocm runtime.

Expand Down
3 changes: 3 additions & 0 deletions python/tvm/topi/arm_cpu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# pylint: disable=wildcard-import
"""Schedule for ARM CPU"""

from .conv1d import *
from .conv2d import *
from .depthwise_conv2d import *
from .conv2d_transpose import *
Expand All @@ -27,3 +28,5 @@
from .injective import *
from . import cortex_m7
from .group_conv2d import *
from .pooling import *
from .dense import *
36 changes: 36 additions & 0 deletions python/tvm/topi/arm_cpu/conv1d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=invalid-name, unused-variable, no-else-return, unused-argument, import-outside-toplevel
"""Conv1D schedule for ARM CPU"""
from __future__ import absolute_import as _abs

from tvm import autotvm

from .cortex_m7.conv1d import direct_simd


@autotvm.register_topi_compute("conv1d_nwc_direct_simd.arm_cpu")
def conv1d_nwc_direct_simd(cfg, data, kernel, strides, padding, dilation, out_dtype):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are better known as DSP instructions rather than SIMD. While these are SIMD instructions on the integer register set, the presence of the MVE instruction set will cause more confusion in the future and thus sticking to consistent names from the architecture would be more appropriate.

Please update this everywhere.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this makes sense--the simd was a historical thing from our initial implementation. i'm good with renaming this e.g. conv1d_nwc_dsp.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, we will change all "direct_simd" parts in naming to "dsp". Also files "direct_simd.py" to rename to "dsp.py", right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggested a file structure such as:

arm_cpu/mprofile/dsp/conv1d.py

This leaves room to add other architecture extensions in future rather than stacking them all in one directory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mprofile seems good to me.

"""Compute conv1d with v7e-m DSP instructions."""
return direct_simd.conv1d_nwc_direct_simd_compute(
cfg, data, kernel, strides, padding, dilation, out_dtype
)


@autotvm.register_topi_schedule("conv1d_nwc_direct_simd.arm_cpu")
def schedule_conv1d_nwc_direct_simd(cfg, outs):
return direct_simd.conv1d_nwc_direct_simd_schedule(cfg, outs)
16 changes: 8 additions & 8 deletions python/tvm/topi/arm_cpu/conv2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,15 +505,15 @@ def _callback(op):
return s


@autotvm.register_topi_compute("conv2d_direct_simd.arm_cpu")
def conv2d_direct_simd(cfg, data, kernel, strides, padding, dilation, out_dtype):
"""Compute conv2d with SIMD (v7e-m)."""
return direct_simd.conv2d_direct_simd_compute(
@autotvm.register_topi_compute("conv2d_nhwc_direct_simd.arm_cpu")
def conv2d_nhwc_direct_simd(cfg, data, kernel, strides, padding, dilation, out_dtype):
"""Compute conv2d_nhwc with v7e-m DSP instructions."""
return direct_simd.conv2d_nhwc_direct_simd_compute(
cfg, data, kernel, strides, padding, dilation, out_dtype
)


@autotvm.register_topi_schedule("conv2d_direct_simd.arm_cpu")
def schedule_conv2d_direct_simd(cfg, outs):
"""Create schedule for conv2d_direct_simd"""
return direct_simd.conv2d_direct_simd_nhwc_schedule(cfg, outs)
@autotvm.register_topi_schedule("conv2d_nhwc_direct_simd.arm_cpu")
def schedule_conv2d_nhwc_direct_simd(cfg, outs):
"""Create schedule for conv2d_nhwc_direct_simd"""
return direct_simd.conv2d_nhwc_direct_simd_schedule(cfg, outs)
3 changes: 2 additions & 1 deletion python/tvm/topi/arm_cpu/cortex_m7/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""Schedules specialized for cortex-m7."""
"""Schedules specialized for v7e-m DSP instructions."""


from . import conv2d
from . import dense
19 changes: 19 additions & 0 deletions python/tvm/topi/arm_cpu/cortex_m7/conv1d/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""Conv1d implementations for v7e-m DSP instructions."""

from . import direct_simd
Loading