[CMSIS-NN] Convert CMSIS-NN to use Target Hooks#9397
Conversation
This migrates CMSIS-NN to use Target Hooks instead of fully BYOC, which means it will now go through any central passes the Driver API. Found a few things whilst doing this: * Forgot to mutate PrimFunc arguments in LowerTE which meant functions weren't getting lowered passed the first function in test_networks * Target `cmsis-nn` needs to match external code generator `cmsis-nn` to connect the Target with the external code generator * Partition Graph needed to sanitise compiler names to generate them properly in C
|
CC @ashutosh-arm @manupa-arm |
| namespace cmsisnn { | ||
|
|
||
| class RelayToTIRVisitor : public MixedModeVisitor { | ||
| class RelayToTIRVisitor : public MixedModeMutator { |
There was a problem hiding this comment.
Should it be renamed RelayToTIRVisitor --> RelayToTIRMutator?
There was a problem hiding this comment.
I'll move this to a follow up 😸
There was a problem hiding this comment.
Sorry, I didn't mean it as a blocking comment. A follow up is fine, should've marked as nit.
| namespace cmsisnn { | ||
|
|
||
| class CodeGenCMSISNN : public CodeGenC { | ||
| class CodeGenCMSISNN : public codegen::CodeGenCHost { |
There was a problem hiding this comment.
Its great that its working with CodeGenCHost now. Just looks tiny bit odd that we are generating target code by deriving from Host codegen. But I also want to say that I don't have any real problem if it works.
There was a problem hiding this comment.
In other Targets they get PrimFunc's which are essentially:
{ [Host Module] -> [Device Lib Module] } -> [Device]
So conceptually it makes sense to do:
{ [Host Module] } -> [Lib]
For CMSIS-NN and other library targets, as TVM is hosting the library - I think, would be interested in @manupa-arm's view here.
manupak
left a comment
There was a problem hiding this comment.
LGTM modulo the existing comments.
|
@ashutosh-arm could you take a look and explicitly approve if it's ok to move the name change to a follow up 😸 |
|
Thanks @Mousius @ashutosh-arm ! |
* main: (119 commits) [Topi][Op][PyTorch][Vitas] Fix inconsistent kernel layout conventions for conv2d_transpose (apache#9336) Fix repository URL in ubuntu_install_rocm.sh (apache#9425) Add LLVM-13 installation to Docker setup (apache#9498) [Relay] Use target_host determined at Relay level instead of recalculating it (apache#9499) Arm(R) Ethos(TM)-U NPU BinaryElementwise operators support (apache#9442) [COMMUNITY] Junru's and Wuwei's PGP key for ASF release (apache#9488) Add default for split op (apache#9489) [HOTFIX][TARGET] Change LOG in compilation config to DLOG (apache#9486) Fixed some warnings about lambda's closures that are bigger than necessary (apache#9481) [Support] Add libinfo into the runtime build (apache#9310) Change Call with TIRCallAttrs to call_lowered op (apache#9312) [ETHOSN] Streamline Ethos(TM)-N cross-compile rpc usage (apache#9477) [CMSIS-NN] Assert correct amount of CMSIS-NN artifacts in MLF (apache#9480) [MicroTVM][PyTest] Explicitly skip MicroTVM unittests. (apache#9335) [microNPU] Replace ICHECK with diagnostic context in type inference (apache#9470) Better host handling in CompilationConfig & debug printing (apache#9460) [AOT][Tests] Use pre-built libraries in Reference System tests (apache#9271) [TIR] Add type hint for TIR (apache#9432) [TVMC] Add test for quantized pytorch model (apache#9467) [CMSIS-NN] Convert CMSIS-NN to use Target Hooks (apache#9397) ...
* [CMSIS-NN] Convert CMSIS-NN to use Target Hooks This migrates CMSIS-NN to use Target Hooks instead of fully BYOC, which means it will now go through any central passes the Driver API. * Mutated PrimFunc arguments in LowerTE so all functions are correctly lowered * Made Target `cmsis-nn` to match external code generator `cmsis-nn` to connect the Target with the external code generator * Modified Partition Graph to sanitise compiler names to generate them properly in C * Port tvmc fixes for hybrid targets * Update NPU tests with new sanitisation
* [CMSIS-NN] Convert CMSIS-NN to use Target Hooks This migrates CMSIS-NN to use Target Hooks instead of fully BYOC, which means it will now go through any central passes the Driver API. * Mutated PrimFunc arguments in LowerTE so all functions are correctly lowered * Made Target `cmsis-nn` to match external code generator `cmsis-nn` to connect the Target with the external code generator * Modified Partition Graph to sanitise compiler names to generate them properly in C * Port tvmc fixes for hybrid targets * Update NPU tests with new sanitisation
* [CMSIS-NN] Convert CMSIS-NN to use Target Hooks This migrates CMSIS-NN to use Target Hooks instead of fully BYOC, which means it will now go through any central passes the Driver API. * Mutated PrimFunc arguments in LowerTE so all functions are correctly lowered * Made Target `cmsis-nn` to match external code generator `cmsis-nn` to connect the Target with the external code generator * Modified Partition Graph to sanitise compiler names to generate them properly in C * Port tvmc fixes for hybrid targets * Update NPU tests with new sanitisation
* [CMSIS-NN] Convert CMSIS-NN to use Target Hooks This migrates CMSIS-NN to use Target Hooks instead of fully BYOC, which means it will now go through any central passes the Driver API. * Mutated PrimFunc arguments in LowerTE so all functions are correctly lowered * Made Target `cmsis-nn` to match external code generator `cmsis-nn` to connect the Target with the external code generator * Modified Partition Graph to sanitise compiler names to generate them properly in C * Port tvmc fixes for hybrid targets * Update NPU tests with new sanitisation
* [CMSIS-NN] Convert CMSIS-NN to use Target Hooks This migrates CMSIS-NN to use Target Hooks instead of fully BYOC, which means it will now go through any central passes the Driver API. * Mutated PrimFunc arguments in LowerTE so all functions are correctly lowered * Made Target `cmsis-nn` to match external code generator `cmsis-nn` to connect the Target with the external code generator * Modified Partition Graph to sanitise compiler names to generate them properly in C * Port tvmc fixes for hybrid targets * Update NPU tests with new sanitisation
This migrates CMSIS-NN to use Target Hooks instead of fully BYOC, which
means it will now go through any central passes the Driver API.
Found a few things whilst doing this:
cmsis-nnneeds to match external code generatorcmsis-nnto connect the Target with the external code generator