| # sparrow_modules() |
| # |
| # A wrapper for the sparrow_static_module and sparrow_vmvx_module to apply common iree-compile flags |
| # Parameters: |
| # NAME: Name of target. |
| # SRC: Source file to compile into a bytecode module. Support relative path. |
| # FLAGS: Flags to pass to the translation tool (list of strings). |
| # C_IDENTIFIER: Identifier to use for generate c embed code. |
| # If omitted then no C embed code will be generated. |
| # TFLITE_OUTPUT: TFLite output array name |
| # RVV_OFF: Indicate RVV is OFF (default: ON) |
| # VMVX: Compile VMVX backend |
| # INLINE_HAL: Use inline HAL. |
| # |
| # Examples: |
| # sparrow_modules( |
| # NAME |
| # dare_devel |
| # SRC |
| # "daredevil_quant.tflite" |
| # C_IDENTIFIER |
| # "daredevil_bytecode_module_static" |
| # FLAGS |
| # "-iree-input-type=tosa" |
| # ) |
| # |
| # sparrow_modules( |
| # NAME |
| # simple_float_mul |
| # SRC |
| # "simple_float_mul.mlir" |
| # C_IDENTIFIER |
| # "simple_float_mul" |
| # FLAGS |
| # "-iree-input-type=mhlo" |
| # RVV_OFF |
| # PUBLIC |
| # ) |
| # |
| |
| function(sparrow_modules) |
| cmake_parse_arguments( |
| _RULE |
| "PUBLIC;RVV_OFF;VMVX;INLINE_HAL" |
| "NAME;SRC;C_IDENTIFIER;TFLITE_OUTPUT" |
| "FLAGS" |
| ${ARGN} |
| ) |
| |
| if (${_RULE_RVV_OFF} OR (NOT ${BUILD_WITH_RVV})) |
| set(_RVV_OFF_ARG "RVV_OFF") |
| endif() |
| |
| if (${_RULE_INLINE_HAL}) |
| set(_INLINE_HAL_ARG "INLINE_HAL") |
| endif() |
| |
| sparrow_static_module( |
| NAME |
| "${_RULE_NAME}_bytecode_module_static" |
| SRC |
| "${_RULE_SRC}" |
| C_IDENTIFIER |
| "${_RULE_C_IDENTIFIER}_bytecode_module_static" |
| TFLITE_OUTPUT |
| "${_RULE_TFLITE_OUTPUT}" |
| FLAGS |
| "${_RULE_FLAGS}" |
| "${_RVV_OFF_ARG}" |
| "${_INLINE_HAL_ARG}" |
| ) |
| |
| sparrow_static_module( |
| NAME |
| "${_RULE_NAME}_c_module_static" |
| SRC |
| "${_RULE_SRC}" |
| TFLITE_OUTPUT |
| "${_RULE_TFLITE_OUTPUT}" |
| FLAGS |
| "${_RULE_FLAGS}" |
| "${_RVV_OFF_ARG}" |
| "${_INLINE_HAL_ARG}" |
| EMITC |
| ) |
| |
| if (${_RULE_VMVX}) |
| sparrow_vmvx_module( |
| NAME |
| "${_RULE_NAME}_bytecode_module_vmvx" |
| SRC |
| "${_RULE_SRC}" |
| C_IDENTIFIER |
| "${_RULE_C_IDENTIFIER}_bytecode_module_vmvx" |
| TFLITE_OUTPUT |
| "${_RULE_TFLITE_OUTPUT}" |
| FLAGS |
| "${_RULE_FLAGS}" |
| "${_INLINE_HAL_ARG}" |
| ) |
| |
| sparrow_vmvx_module( |
| NAME |
| "${_RULE_NAME}_c_module_vmvx" |
| SRC |
| "${_RULE_SRC}" |
| TFLITE_OUTPUT |
| "${_RULE_TFLITE_OUTPUT}" |
| FLAGS |
| "${_RULE_FLAGS}" |
| "${_INLINE_HAL_ARG}" |
| EMITC |
| ) |
| endif() |
| |
| endfunction() |