Add HPS model input support for WMMU Simulations
For WMMU Simulations, point the HPS model input to 0x84000000.
Change-Id: I945199f2719dd5a16b8073550be27faf976882bb
diff --git a/quant_models/CMakeLists.txt b/quant_models/CMakeLists.txt
index 50ca35a..42cdca3 100644
--- a/quant_models/CMakeLists.txt
+++ b/quant_models/CMakeLists.txt
@@ -115,46 +115,51 @@
# to increase it.
foreach(N 0 1 2 3 4 5 6)
-iree_cc_binary(
- NAME
- hps_${N}_bytecode_static
- SRCS
- "iree_exec/hps.c"
- DEPS
- ::hps_${N}_quant_input_c
- ::hps_bytecode_module_static_c
- ::hps_bytecode_module_static_lib
- iree::vm::bytecode_module
- model_util::util_static
- COPTS
- "-DHPS_IDX=${N}"
- LINKOPTS
- "LINKER:--defsym=__stack_size__=200k"
- # TODO(b/241297921): determine HPS heap size
- "LINKER:--defsym=__heap_size__=5M"
-)
+ set(HPS_COPTS "-DHPS_IDX=${N}")
+ if (NOT BUILD_NO_WMMU)
+ list(APPEND HPS_COPTS "-DNO_STATIC_INPUT")
+ endif()
-springbok_test(
- NAME
- hps_${N}_emitc_static
- SRCS
- "iree_exec/hps.c"
- DEPS
- ::hps_${N}_quant_input_c
- ::hps_c_module_static_emitc
- ::hps_c_module_static_lib
- model_util::util_static
- LINKOPTS
- "LINKER:--defsym=__stack_size__=200k"
- # TODO(b/241297921): determine HPS heap size
- "LINKER:--defsym=__heap_size__=5M"
- COPTS
- "-DHPS_IDX=${N}"
- "-DBUILD_EMITC"
- TESTFILES
- "iree_exec/hps_test.run"
- "iree_exec/hps_${N}_test.filecheck"
-)
+ iree_cc_binary(
+ NAME
+ hps_${N}_bytecode_static
+ SRCS
+ "iree_exec/hps.c"
+ DEPS
+ ::hps_${N}_quant_input_c
+ ::hps_bytecode_module_static_c
+ ::hps_bytecode_module_static_lib
+ iree::vm::bytecode_module
+ model_util::util_static
+ COPTS
+ ${HPS_COPTS}
+ LINKOPTS
+ "LINKER:--defsym=__stack_size__=200k"
+ # TODO(b/241297921): determine HPS heap size
+ "LINKER:--defsym=__heap_size__=5M"
+ )
+
+ springbok_test(
+ NAME
+ hps_${N}_emitc_static
+ SRCS
+ "iree_exec/hps.c"
+ DEPS
+ ::hps_${N}_quant_input_c
+ ::hps_c_module_static_emitc
+ ::hps_c_module_static_lib
+ model_util::util_static
+ LINKOPTS
+ "LINKER:--defsym=__stack_size__=200k"
+ # TODO(b/241297921): determine HPS heap size
+ "LINKER:--defsym=__heap_size__=5M"
+ COPTS
+ ${HPS_COPTS}
+ "-DBUILD_EMITC"
+ TESTFILES
+ "iree_exec/hps_test.run"
+ "iree_exec/hps_${N}_test.filecheck"
+ )
endforeach()
iree_cc_binary(
diff --git a/quant_models/iree_exec/hps.c b/quant_models/iree_exec/hps.c
index 5537c29..1b23f02 100644
--- a/quant_models/iree_exec/hps.c
+++ b/quant_models/iree_exec/hps.c
@@ -24,6 +24,7 @@
#include "iree/hal/api.h"
#include "model_util/util.h"
+#if !defined(NO_STATIC_INPUT)
#if HPS_IDX == 0
#include "hps_0_quant_input_c.h"
#define HPS_QUANT_INPUT hps_0_quant_input
@@ -46,6 +47,10 @@
#include "hps_1_quant_input_c.h"
#define HPS_QUANT_INPUT hps_1_quant_input
#endif
+static const void *kInput = HPS_QUANT_INPUT;
+#else
+static const void *kInput = (const void *)0x84000000;
+#endif // if !defined(NO_STATIC_INPUT)
// Compiled module embedded here to avoid file IO:
#if !defined(BUILD_EMITC)
@@ -84,7 +89,7 @@
iree_const_byte_span_t **byte_span) {
byte_span[0] = malloc(sizeof(iree_const_byte_span_t));
*byte_span[0] = iree_make_const_byte_span(
- HPS_QUANT_INPUT, model->input_size_bytes[0] * model->input_length[0]);
+ kInput, model->input_size_bytes[0] * model->input_length[0]);
return iree_ok_status();
}