Remove internal float model support As internal float models are no longer needed at this point, we remove the support for them to clean up codes. Change-Id: Ieaa2478e2dfe44b42261db1485ba784122b797b3
diff --git a/samples/float_model_embedding/CMakeLists.txt b/samples/float_model_embedding/CMakeLists.txt index 029609e..7ad8100 100644 --- a/samples/float_model_embedding/CMakeLists.txt +++ b/samples/float_model_embedding/CMakeLists.txt
@@ -33,117 +33,6 @@ PUBLIC ) -if(${BUILD_INTERNAL_MODELS}) - -if(NOT ${BUILD_WITH_SPRINGBOK}) - springbok_bytecode_module( - NAME - scenenet_v2_bytecode_module_dylib - SRC - "$ENV{ROOTDIR}/ml/ml-models/float_models/scenenet_v2_float.tflite" - C_IDENTIFIER - "samples_float_model_embedding_scenenet_v2_bytecode_module_dylib" - FLAGS - "-iree-input-type=tosa" - "-riscv-v-vector-bits-min=512" - "-riscv-v-fixed-length-vector-lmul-max=8" - "-riscv-v-fixed-length-vector-elen-max=32" - PUBLIC - ) - - springbok_bytecode_module( - NAME - barcode_bytecode_module_dylib - SRC - "$ENV{ROOTDIR}/ml/ml-models/float_models/barcode_float.tflite" - C_IDENTIFIER - "samples_float_model_embedding_barcode_bytecode_module_dylib" - FLAGS - "-iree-input-type=tosa" - "-riscv-v-vector-bits-min=512" - "-riscv-v-fixed-length-vector-lmul-max=8" - "-riscv-v-fixed-length-vector-elen-max=32" - PUBLIC - ) -endif() - -springbok_bytecode_module( - NAME - daredevil_bytecode_module_dylib - SRC - "$ENV{ROOTDIR}/ml/ml-models/float_models/daredevil_float.tflite" - C_IDENTIFIER - "samples_float_model_embedding_daredevil_bytecode_module_dylib" - FLAGS - "-iree-input-type=tosa" - "-riscv-v-vector-bits-min=512" - "-riscv-v-fixed-length-vector-lmul-max=8" - "-riscv-v-fixed-length-vector-elen-max=32" - PUBLIC -) - -springbok_bytecode_module( - NAME - fssd_25_8bit_v2_bytecode_module_dylib - SRC - "$ENV{ROOTDIR}/ml/ml-models/float_models/fssd_25_8bit_v2_float.tflite" - C_IDENTIFIER - "samples_float_model_embedding_fssd_25_8bit_v2_bytecode_module_dylib" - FLAGS - "-iree-input-type=tosa" - "-riscv-v-vector-bits-min=512" - "-riscv-v-fixed-length-vector-lmul-max=8" - "-riscv-v-fixed-length-vector-elen-max=32" - PUBLIC -) - -springbok_bytecode_module( - NAME - person_detection_bytecode_module_dylib - SRC - "$ENV{ROOTDIR}/ml/ml-models/float_models/person_detection_float.tflite" - C_IDENTIFIER - "samples_float_model_embedding_person_detection_bytecode_module_dylib" - FLAGS - "-iree-input-type=tosa" - "-riscv-v-vector-bits-min=512" - "-riscv-v-fixed-length-vector-lmul-max=8" - "-riscv-v-fixed-length-vector-elen-max=32" - PUBLIC -) - -springbok_bytecode_module( - NAME - semantic_lift_bytecode_module_dylib - SRC - "$ENV{ROOTDIR}/ml/ml-models/float_models/semantic_lift_float.tflite" - C_IDENTIFIER - "samples_float_model_embedding_semantic_lift_bytecode_module_dylib" - FLAGS - "-iree-input-type=tosa" - "-riscv-v-vector-bits-min=512" - "-riscv-v-fixed-length-vector-lmul-max=8" - "-riscv-v-fixed-length-vector-elen-max=32" - PUBLIC -) - -springbok_bytecode_module( - NAME - voice_commands_bytecode_module_dylib - SRC - "$ENV{ROOTDIR}/ml/ml-models/float_models/voice_commands_float.tflite" - C_IDENTIFIER - "samples_float_model_embedding_voice_commands_bytecode_module_dylib" - FLAGS - "-iree-input-type=tosa" - "-riscv-v-vector-bits-min=512" - "-riscv-v-fixed-length-vector-lmul-max=8" - "-riscv-v-fixed-length-vector-elen-max=32" - PUBLIC -) - -endif(${BUILD_INTERNAL_MODELS}) - #------------------------------------------------------------------------------- # Binaries to execute the IREE model input #------------------------------------------------------------------------------- @@ -170,20 +59,6 @@ "0, 1" ) -if(${BUILD_INTERNAL_MODELS}) - -iree_model_input( - NAME - person_detection_input - SHAPE - "1, 96, 96, 1" - SRC - "https://github.com/tensorflow/tflite-micro/raw/aeac6f39e5c7475cea20c54e86d41e3a38312546/ \ - tensorflow/lite/micro/examples/person_detection/testdata/person.bmp" -) - -endif(${BUILD_INTERNAL_MODELS}) - #------------------------------------------------------------------------------- # Binaries to execute the MLIR bytecode modules #------------------------------------------------------------------------------- @@ -223,92 +98,3 @@ LINKOPTS "LINKER:--defsym=__stack_size__=100k" ) - -if(NOT ${BUILD_INTERNAL_MODELS}) - return() -endif() - -if(NOT ${BUILD_WITH_SPRINGBOK}) - iree_cc_binary( - NAME - scenenet_v2_embedded_sync - SRCS - "scenenet_v2.c" - DEPS - ::scenenet_v2_bytecode_module_dylib_c - samples::util::util - ) - - iree_cc_binary( - NAME - barcode_embedded_sync - SRCS - "barcode.c" - DEPS - ::barcode_bytecode_module_dylib_c - samples::util::util - LINKOPTS - "LINKER:--defsym=__stack_size__=100k" - ) -endif() - -iree_cc_binary( - NAME - daredevil_embedded_sync - SRCS - "daredevil.c" - DEPS - ::daredevil_bytecode_module_dylib_c - samples::util::util - LINKOPTS - "LINKER:--defsym=__stack_size__=100k" -) - -iree_cc_binary( - NAME - fssd_25_8bit_v2_embedded_sync - SRCS - "fssd_25_8bit_v2.c" - DEPS - ::fssd_25_8bit_v2_bytecode_module_dylib_c - samples::util::util - LINKOPTS - "LINKER:--defsym=__stack_size__=100k" -) - -iree_cc_binary( - NAME - person_detection_embedded_sync - SRCS - "person_detection.c" - DEPS - ::person_detection_bytecode_module_dylib_c - ::person_detection_input_c - samples::util::util - LINKOPTS - "LINKER:--defsym=__stack_size__=100k" -) - -iree_cc_binary( - NAME - semantic_lift_embedded_sync - SRCS - "semantic_lift.c" - DEPS - ::semantic_lift_bytecode_module_dylib_c - samples::util::util - LINKOPTS - "LINKER:--defsym=__stack_size__=100k" -) - -iree_cc_binary( - NAME - voice_commands_embedded_sync - SRCS - "voice_commands.c" - DEPS - ::voice_commands_bytecode_module_dylib_c - samples::util::util - LINKOPTS - "LINKER:--defsym=__stack_size__=100k" -)
diff --git a/samples/float_model_embedding/barcode.c b/samples/float_model_embedding/barcode.c deleted file mode 100644 index b49bea8..0000000 --- a/samples/float_model_embedding/barcode.c +++ /dev/null
@@ -1,62 +0,0 @@ -// Barcode float model -// MlModel struct initialization to include model I/O info. -// Bytecode loading, input/output processes. - -#include <springbok.h> - -#include "iree/base/api.h" -#include "iree/hal/api.h" -#include "samples/util/util.h" - -// Compiled module embedded here to avoid file IO: -#include "samples/float_model_embedding/barcode_bytecode_module_dylib_c.h" - -const MlModel kModel = { - .num_input = 1, - .num_input_dim = {4}, - .input_shape = {{1, 320, 320, 1}}, - .input_length = {320 * 320 * 1}, - .input_size_bytes = {sizeof(float)}, - .num_output = 12, - .output_length = {20 * 20 * 36, 20 * 20 * 9, 10 * 10 * 72, 10 * 10 * 18, - 5 * 5 * 72, 5 * 5 * 18, 3 * 3 * 72, 3 * 3 * 18, - 2 * 2 * 72, 2 * 2 * 18, 72, 18}, - .output_size_bytes = sizeof(float), - .hal_element_type = IREE_HAL_ELEMENT_TYPE_FLOAT_32, - .entry_func = "module.main", - .model_name = "barcode_float", -}; - -const iree_const_byte_span_t load_bytecode_module_data() { - const struct iree_file_toc_t *module_file_toc = - samples_float_model_embedding_barcode_bytecode_module_dylib_create(); - return iree_make_const_byte_span(module_file_toc->data, - module_file_toc->size); -} - -iree_status_t load_input_data(const MlModel *model, void **buffer) { - iree_status_t result = alloc_input_buffer(model, buffer); - // Populate initial value - srand(768954); - if (iree_status_is_ok(result)) { - for (int i = 0; i < model->input_length[0]; ++i) { - int x = rand(); - ((float *)*buffer)[i] = (float)x / (float)RAND_MAX; - } - } - return result; -} - -iree_status_t check_output_data(const MlModel *model, - iree_hal_buffer_mapping_t *mapped_memory, - int index_output) { - iree_status_t result = iree_ok_status(); - if (index_output > model->num_output || - mapped_memory->contents.data_length / model->output_size_bytes != - model->output_length[index_output]) { - result = iree_make_status(IREE_STATUS_UNKNOWN, "output length mismatches"); - } - LOG_INFO("Output #%d data length: %d", index_output, - mapped_memory->contents.data_length / model->output_size_bytes); - return result; -}
diff --git a/samples/float_model_embedding/daredevil.c b/samples/float_model_embedding/daredevil.c deleted file mode 100644 index 660910a..0000000 --- a/samples/float_model_embedding/daredevil.c +++ /dev/null
@@ -1,60 +0,0 @@ -// Daredevil float model -// MlModel struct initialization to include model I/O info. -// Bytecode loading, input/output processes. - -#include <springbok.h> - -#include "iree/base/api.h" -#include "iree/hal/api.h" -#include "samples/util/util.h" - -// Compiled module embedded here to avoid file IO: -#include "samples/float_model_embedding/daredevil_bytecode_module_dylib_c.h" - -const MlModel kModel = { - .num_input = 1, - .num_input_dim = {3}, - .input_shape = {{1, 96, 64}}, - .input_length = {96 * 64}, - .input_size_bytes = {sizeof(float)}, - .num_output = 1, - .output_length = {527}, - .output_size_bytes = sizeof(float), - .hal_element_type = IREE_HAL_ELEMENT_TYPE_FLOAT_32, - .entry_func = "module.main", - .model_name = "daredevil_float", -}; - -const iree_const_byte_span_t load_bytecode_module_data() { - const struct iree_file_toc_t *module_file_toc = - samples_float_model_embedding_daredevil_bytecode_module_dylib_create(); - return iree_make_const_byte_span(module_file_toc->data, - module_file_toc->size); -} - -iree_status_t load_input_data(const MlModel *model, void **buffer) { - iree_status_t result = alloc_input_buffer(model, buffer); - // Populate initial value - srand(3689964); - if (iree_status_is_ok(result)) { - for (int i = 0; i < model->input_length[0]; ++i) { - int x = rand(); - ((float *)*buffer)[i] = (float)x / (float)RAND_MAX; - } - } - return result; -} - -iree_status_t check_output_data(const MlModel *model, - iree_hal_buffer_mapping_t *mapped_memory, - int index_output) { - iree_status_t result = iree_ok_status(); - if (index_output > model->num_output || - mapped_memory->contents.data_length / model->output_size_bytes != - model->output_length[index_output]) { - result = iree_make_status(IREE_STATUS_UNKNOWN, "output length mismatches"); - } - LOG_INFO("Output #%d data length: %d", index_output, - mapped_memory->contents.data_length / model->output_size_bytes); - return result; -}
diff --git a/samples/float_model_embedding/fssd_25_8bit_v2.c b/samples/float_model_embedding/fssd_25_8bit_v2.c deleted file mode 100644 index b3cf4aa..0000000 --- a/samples/float_model_embedding/fssd_25_8bit_v2.c +++ /dev/null
@@ -1,60 +0,0 @@ -// Fssd_25_8bit_v2 float model -// MlModel struct initialization to include model I/O info. -// Bytecode loading, input/output processes. - -#include <springbok.h> - -#include "iree/base/api.h" -#include "iree/hal/api.h" -#include "samples/util/util.h" - -// Compiled module embedded here to avoid file IO: -#include "samples/float_model_embedding/fssd_25_8bit_v2_bytecode_module_dylib_c.h" - -const MlModel kModel = { - .num_input = 1, - .num_input_dim = {4}, - .input_shape = {{1, 320, 320, 3}}, - .input_length = {320 * 320 * 3}, - .input_size_bytes = {sizeof(float)}, - .num_output = 2, - .output_length = {1602, 1602 * 16}, - .output_size_bytes = sizeof(float), - .hal_element_type = IREE_HAL_ELEMENT_TYPE_FLOAT_32, - .entry_func = "module.main", - .model_name = "fssd_25_8bit_v2_float", -}; - -const iree_const_byte_span_t load_bytecode_module_data() { - const struct iree_file_toc_t *module_file_toc = - samples_float_model_embedding_fssd_25_8bit_v2_bytecode_module_dylib_create(); - return iree_make_const_byte_span(module_file_toc->data, - module_file_toc->size); -} - -iree_status_t load_input_data(const MlModel *model, void **buffer) { - iree_status_t result = alloc_input_buffer(model, buffer); - // Populate initial value - srand(11111111); - if (iree_status_is_ok(result)) { - for (int i = 0; i < model->input_length[0]; ++i) { - int x = rand(); - ((float *)*buffer)[i] = (float)x / (float)RAND_MAX; - } - } - return result; -} - -iree_status_t check_output_data(const MlModel *model, - iree_hal_buffer_mapping_t *mapped_memory, - int index_output) { - iree_status_t result = iree_ok_status(); - if (index_output > model->num_output || - mapped_memory->contents.data_length / model->output_size_bytes != - model->output_length[index_output]) { - result = iree_make_status(IREE_STATUS_UNKNOWN, "output length mismatches"); - } - LOG_INFO("Output #%d data length: %d", index_output, - mapped_memory->contents.data_length / model->output_size_bytes); - return result; -}
diff --git a/samples/float_model_embedding/person_detection.c b/samples/float_model_embedding/person_detection.c deleted file mode 100644 index a892093..0000000 --- a/samples/float_model_embedding/person_detection.c +++ /dev/null
@@ -1,66 +0,0 @@ -// Person_detection float model -// MlModel struct initialization to include model I/O info. -// Bytecode loading, input/output processes. - -#include <springbok.h> - -#include "iree/base/api.h" -#include "iree/hal/api.h" -#include "samples/util/util.h" - -// Compiled module embedded here to avoid file IO: -#include "samples/float_model_embedding/person_detection_bytecode_module_dylib_c.h" -#include "samples/float_model_embedding/person_detection_input_c.h" - -const MlModel kModel = { - .num_input = 1, - .num_input_dim = {4}, - .input_shape = {{1, 96, 96, 1}}, - .input_length = {96 * 96 * 1}, - .input_size_bytes = {sizeof(float)}, - .num_output = 1, - .output_length = {2}, - .output_size_bytes = sizeof(float), - .hal_element_type = IREE_HAL_ELEMENT_TYPE_FLOAT_32, - .entry_func = "module.main", - .model_name = "person_detection_float", -}; - -const iree_const_byte_span_t load_bytecode_module_data() { - const struct iree_file_toc_t *module_file_toc = - samples_float_model_embedding_person_detection_bytecode_module_dylib_create(); - return iree_make_const_byte_span(module_file_toc->data, - module_file_toc->size); -} - -iree_status_t load_input_data(const MlModel *model, void **buffer) { - iree_status_t result = alloc_input_buffer(model, buffer); - const struct iree_file_toc_t *input_file_toc = - person_detection_input_c_create(); - memcpy(*buffer, input_file_toc->data, input_file_toc->size); - return result; -} - -iree_status_t check_output_data(const MlModel *model, - iree_hal_buffer_mapping_t *mapped_memory, - int index_output) { - iree_status_t result = iree_ok_status(); - if (index_output > model->num_output || - mapped_memory->contents.data_length / model->output_size_bytes != - model->output_length[index_output]) { - result = iree_make_status(IREE_STATUS_UNKNOWN, "output length mismatches"); - } - LOG_INFO("Output #%d data length: %d", index_output, - mapped_memory->contents.data_length / model->output_size_bytes); - - float *data = (float *)mapped_memory->contents.data; - char buffer[20]; - int chars_needed = float_to_str(0, NULL, data[0]); - float_to_str(chars_needed, buffer, data[0]); - LOG_INFO("Output: Non-person Score: %s", buffer); - chars_needed = float_to_str(0, NULL, data[1]); - float_to_str(chars_needed, buffer, data[1]); - LOG_INFO("Output: Person Score: %s", buffer); - - return result; -}
diff --git a/samples/float_model_embedding/scenenet_v2.c b/samples/float_model_embedding/scenenet_v2.c deleted file mode 100644 index 6c1b316..0000000 --- a/samples/float_model_embedding/scenenet_v2.c +++ /dev/null
@@ -1,60 +0,0 @@ -// Scenenet_v2 float model -// MlModel struct initialization to include model I/O info. -// Bytecode loading, input/output processes. - -#include <springbok.h> - -#include "iree/base/api.h" -#include "iree/hal/api.h" -#include "samples/util/util.h" - -// Compiled module embedded here to avoid file IO: -#include "samples/float_model_embedding/scenenet_v2_bytecode_module_dylib_c.h" - -const MlModel kModel = { - .num_input = 1, - .num_input_dim = {4}, - .input_shape = {{1, 192, 192, 3}}, - .input_length = {192 * 192 * 3}, - .input_size_bytes = {sizeof(float)}, - .num_output = 1, - .output_length = {170}, - .output_size_bytes = sizeof(float), - .hal_element_type = IREE_HAL_ELEMENT_TYPE_FLOAT_32, - .entry_func = "module.main", - .model_name = "scenenet_v2_float", -}; - -const iree_const_byte_span_t load_bytecode_module_data() { - const struct iree_file_toc_t *module_file_toc = - samples_float_model_embedding_scenenet_v2_bytecode_module_dylib_create(); - return iree_make_const_byte_span(module_file_toc->data, - module_file_toc->size); -} - -iree_status_t load_input_data(const MlModel *model, void **buffer) { - iree_status_t result = alloc_input_buffer(model, buffer); - // Populate initial value - srand(55555555); - if (iree_status_is_ok(result)) { - for (int i = 0; i < model->input_length[0]; ++i) { - int x = rand(); - ((float *)*buffer)[i] = (float)x / (float)RAND_MAX; - } - } - return result; -} - -iree_status_t check_output_data(const MlModel *model, - iree_hal_buffer_mapping_t *mapped_memory, - int index_output) { - iree_status_t result = iree_ok_status(); - if (index_output > model->num_output || - mapped_memory->contents.data_length / model->output_size_bytes != - model->output_length[index_output]) { - result = iree_make_status(IREE_STATUS_UNKNOWN, "output length mismatches"); - } - LOG_INFO("Output #%d data length: %d", index_output, - mapped_memory->contents.data_length / model->output_size_bytes); - return result; -}
diff --git a/samples/float_model_embedding/semantic_lift.c b/samples/float_model_embedding/semantic_lift.c deleted file mode 100644 index 7e50f5e..0000000 --- a/samples/float_model_embedding/semantic_lift.c +++ /dev/null
@@ -1,60 +0,0 @@ -// Semantic_lift float model -// MlModel struct initialization to include model I/O info. -// Bytecode loading, input/output processes. - -#include <springbok.h> - -#include "iree/base/api.h" -#include "iree/hal/api.h" -#include "samples/util/util.h" - -// Compiled module embedded here to avoid file IO: -#include "samples/float_model_embedding/semantic_lift_bytecode_module_dylib_c.h" - -const MlModel kModel = { - .num_input = 1, - .num_input_dim = {4}, - .input_shape = {{1, 128, 128, 3}}, - .input_length = {128 * 128 * 3}, - .input_size_bytes = {sizeof(float)}, - .num_output = 2, - .output_length = {2, 2}, - .output_size_bytes = sizeof(float), - .hal_element_type = IREE_HAL_ELEMENT_TYPE_FLOAT_32, - .entry_func = "module.main", - .model_name = "semantic_lift_float", -}; - -const iree_const_byte_span_t load_bytecode_module_data() { - const struct iree_file_toc_t *module_file_toc = - samples_float_model_embedding_semantic_lift_bytecode_module_dylib_create(); - return iree_make_const_byte_span(module_file_toc->data, - module_file_toc->size); -} - -iree_status_t load_input_data(const MlModel *model, void **buffer) { - iree_status_t result = alloc_input_buffer(model, buffer); - // Populate initial value - srand(66666666); - if (iree_status_is_ok(result)) { - for (int i = 0; i < model->input_length[0]; ++i) { - int x = rand(); - ((float *)*buffer)[i] = (float)x / (float)RAND_MAX; - } - } - return result; -} - -iree_status_t check_output_data(const MlModel *model, - iree_hal_buffer_mapping_t *mapped_memory, - int index_output) { - iree_status_t result = iree_ok_status(); - if (index_output > model->num_output || - mapped_memory->contents.data_length / model->output_size_bytes != - model->output_length[index_output]) { - result = iree_make_status(IREE_STATUS_UNKNOWN, "output length mismatches"); - } - LOG_INFO("Output #%d data length: %d", index_output, - mapped_memory->contents.data_length / model->output_size_bytes); - return result; -}
diff --git a/samples/float_model_embedding/voice_commands.c b/samples/float_model_embedding/voice_commands.c deleted file mode 100644 index d6357e9..0000000 --- a/samples/float_model_embedding/voice_commands.c +++ /dev/null
@@ -1,60 +0,0 @@ -// Voice_commands float model -// MlModel struct initialization to include model I/O info. -// Bytecode loading, input/output processes. - -#include <springbok.h> - -#include "iree/base/api.h" -#include "iree/hal/api.h" -#include "samples/util/util.h" - -// Compiled module embedded here to avoid file IO: -#include "samples/float_model_embedding/voice_commands_bytecode_module_dylib_c.h" - -const MlModel kModel = { - .num_input = 1, - .num_input_dim = {3}, - .input_shape = {{1, 198, 32}}, - .input_length = {198 * 32}, - .input_size_bytes = {sizeof(float)}, - .num_output = 1, - .output_length = {63}, - .output_size_bytes = sizeof(float), - .hal_element_type = IREE_HAL_ELEMENT_TYPE_FLOAT_32, - .entry_func = "module.main", - .model_name = "voice_commands_float", -}; - -const iree_const_byte_span_t load_bytecode_module_data() { - const struct iree_file_toc_t *module_file_toc = - samples_float_model_embedding_voice_commands_bytecode_module_dylib_create(); - return iree_make_const_byte_span(module_file_toc->data, - module_file_toc->size); -} - -iree_status_t load_input_data(const MlModel *model, void **buffer) { - iree_status_t result = alloc_input_buffer(model, buffer); - // Populate initial value - srand(77777777); - if (iree_status_is_ok(result)) { - for (int i = 0; i < model->input_length[0]; ++i) { - int x = rand(); - ((float *)*buffer)[i] = (float)x / (float)RAND_MAX; - } - } - return result; -} - -iree_status_t check_output_data(const MlModel *model, - iree_hal_buffer_mapping_t *mapped_memory, - int index_output) { - iree_status_t result = iree_ok_status(); - if (index_output > model->num_output || - mapped_memory->contents.data_length / model->output_size_bytes != - model->output_length[index_output]) { - result = iree_make_status(IREE_STATUS_UNKNOWN, "output length mismatches"); - } - LOG_INFO("Output #%d data length: %d", index_output, - mapped_memory->contents.data_length / model->output_size_bytes); - return result; -}