Enable microkernel VMVX for person_detection model Enable microkernel for VMVX backend and for person_detection model only. Change-Id: Ib91f84e5317b2d0a29a1281d0948177d189cbf0e
diff --git a/quant_models/CMakeLists.txt b/quant_models/CMakeLists.txt index 42cdca3..6dba090 100644 --- a/quant_models/CMakeLists.txt +++ b/quant_models/CMakeLists.txt
@@ -61,6 +61,7 @@ "-iree-input-type=tosa" "-riscv-v-vector-bits-min=512" "-riscv-v-fixed-length-vector-lmul-max=8" + VMVX PUBLIC ) @@ -234,6 +235,43 @@ iree_cc_binary( NAME + person_detection_bytecode_vmvx + SRCS + "iree_exec/person_detection.c" + DEPS + ::person_detection_bytecode_module_vmvx_c + ::person_detection_quant_input_c + iree::vm::bytecode_module + model_util::util_vmvx + LINKOPTS + "LINKER:--defsym=__stack_size__=128k" + "LINKER:--defsym=__heap_size__=200k" + COPTS + "-DBUILD_VMVX" +) + +springbok_test( + NAME + person_detection_emitc_vmvx + SRCS + "iree_exec/person_detection.c" + DEPS + ::person_detection_c_module_vmvx_emitc + ::person_detection_quant_input_c + model_util::util_vmvx + LINKOPTS + "LINKER:--defsym=__stack_size__=128k" + "LINKER:--defsym=__heap_size__=200k" + COPTS + "-DBUILD_EMITC" + "-DBUILD_VMVX" + TESTFILES + "iree_exec/person_detection_vmvx_test.run" + "iree_exec/person_detection_test.filecheck" +) + +iree_cc_binary( + NAME person_detection_bytecode_static SRCS "iree_exec/person_detection.c"
diff --git a/quant_models/iree_exec/person_detection.c b/quant_models/iree_exec/person_detection.c index 6d96146..41bd9c3 100644 --- a/quant_models/iree_exec/person_detection.c +++ b/quant_models/iree_exec/person_detection.c
@@ -26,13 +26,21 @@ #include "iree/hal/api.h" // Compiled module embedded here to avoid file IO: +#if defined(BUILD_VMVX) +#if !defined(BUILD_EMITC) +#include "person_detection_bytecode_module_vmvx_c.h" +#else +#include "person_detection_c_module_vmvx_emitc.h" +#endif // !defined(BUILD_EMITC) +#else #if !defined(BUILD_EMITC) #include "person_detection_bytecode_module_static.h" #include "person_detection_bytecode_module_static_c.h" #else #include "person_detection_c_module_static_c.h" #include "person_detection_c_module_static_emitc.h" -#endif +#endif // !defined(BUILD_EMITC) +#endif // defined(BUILD_VMVX) #include "person_detection_quant_input_c.h" __attribute__((section(".model_output"))) PersonDetectionOutput detection; @@ -40,8 +48,13 @@ iree_status_t create_module(iree_vm_instance_t *instance, iree_vm_module_t **module) { #if !defined(BUILD_EMITC) +#if defined(BUILD_VMVX) + const struct iree_file_toc_t *module_file_toc = + quant_models_person_detection_bytecode_module_vmvx_create(); +#else const struct iree_file_toc_t *module_file_toc = quant_models_person_detection_bytecode_module_static_create(); +#endif return iree_vm_bytecode_module_create( instance, iree_make_const_byte_span(module_file_toc->data, module_file_toc->size), @@ -51,6 +64,7 @@ #endif } +#if !defined(BUILD_VMVX) iree_hal_executable_library_query_fn_t library_query(void) { #if !defined(BUILD_EMITC) return &person_detection_bytecode_module_static_linked_llvm_cpu_library_query; @@ -58,6 +72,7 @@ return &person_detection_c_module_static_linked_llvm_cpu_library_query; #endif } +#endif iree_status_t load_input_data(const MlModel *model, void **buffer, iree_const_byte_span_t **byte_span) {
diff --git a/quant_models/iree_exec/person_detection_test.filecheck b/quant_models/iree_exec/person_detection_test.filecheck index c84bff9..1a880de 100644 --- a/quant_models/iree_exec/person_detection_test.filecheck +++ b/quant_models/iree_exec/person_detection_test.filecheck
@@ -1 +1 @@ -// CHECK: Non-person Score: -113; Person Score: 113 +// CHECK: {{Non-person Score: -11[3-4]; Person Score: 11[3-4]}}
diff --git a/quant_models/iree_exec/person_detection_vmvx_test.run b/quant_models/iree_exec/person_detection_vmvx_test.run new file mode 100644 index 0000000..c0ffdb9 --- /dev/null +++ b/quant_models/iree_exec/person_detection_vmvx_test.run
@@ -0,0 +1,5 @@ +// RUN: ${TEST_RUNNER_CMD} %S/person_detection_bytecode_vmvx 2>&1 | tee %t +// RUN: cat %t | FileCheck %S/person_detection_test.filecheck + +// RUN: ${TEST_RUNNER_CMD} %S/person_detection_emitc_vmvx 2>&1 | tee %t +// RUN: cat %t | FileCheck %S/person_detection_test.filecheck