diff options
Diffstat (limited to 'compiler/enco/test/tflite')
52 files changed, 1046 insertions, 0 deletions
diff --git a/compiler/enco/test/tflite/AveragePool2D_000/INFERENCE b/compiler/enco/test/tflite/AveragePool2D_000/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/AveragePool2D_000/INFERENCE diff --git a/compiler/enco/test/tflite/AveragePool2D_000/test.recipe b/compiler/enco/test/tflite/AveragePool2D_000/test.recipe new file mode 100644 index 000000000..746c34334 --- /dev/null +++ b/compiler/enco/test/tflite/AveragePool2D_000/test.recipe @@ -0,0 +1,24 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 8 dim: 8 dim: 1 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 7 dim: 7 dim: 1 } +} +operation { + type: "AveragePool2D" + averagepool2d_options { + padding: VALID + stride_w: 1 + stride_h: 1 + filter_width: 2 + filter_height: 2 + } + input: "ifm" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/enco/test/tflite/AveragePool2D_001/INFERENCE b/compiler/enco/test/tflite/AveragePool2D_001/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/AveragePool2D_001/INFERENCE diff --git a/compiler/enco/test/tflite/AveragePool2D_001/test.recipe b/compiler/enco/test/tflite/AveragePool2D_001/test.recipe new file mode 100644 index 000000000..36bbda78c --- /dev/null +++ b/compiler/enco/test/tflite/AveragePool2D_001/test.recipe @@ -0,0 +1,24 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 8 dim: 8 dim: 5 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 8 dim: 8 dim: 5 } +} +operation { + type: "AveragePool2D" + averagepool2d_options { + padding: SAME + stride_w: 1 + stride_h: 1 + filter_width: 3 + filter_height: 3 + } + input: "ifm" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/enco/test/tflite/CMakeLists.txt b/compiler/enco/test/tflite/CMakeLists.txt new file mode 100644 index 000000000..d5a96a6da --- /dev/null +++ b/compiler/enco/test/tflite/CMakeLists.txt @@ -0,0 +1,108 @@ +option(ENCO_TFLITE_TEST "Enable enco test for TFLite" ON) + +if(NOT ENCO_TFLITE_TEST) + return() +endif(NOT ENCO_TFLITE_TEST) + +### +### Common function(s) +### +function(get_test_configuration PREFIX) + set(RECIPE_FILE "${PREFIX}.recipe" PARENT_SCOPE) + set(TFLITEMODEL_FILE "${PREFIX}.tflite" PARENT_SCOPE) + set(SOURCE_FILE ${PREFIX}.cpp PARENT_SCOPE) + set(ASM_FILE ${PREFIX}.embed.S PARENT_SCOPE) + set(BIN_FILE ${PREFIX}.bin PARENT_SCOPE) +endfunction(get_test_configuration) + +### +### Prepare test(s) +### +if(NOT TARGET tflchef-file) + return() +endif(NOT TARGET tflchef-file) + +if(NOT TARGET enco_tflite_frontend) + return() +endif(NOT TARGET enco_tflite_frontend) + +file(GLOB MODELS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/test.recipe") + +foreach(MODEL IN ITEMS ${MODELS}) + get_filename_component(PREFIX ${MODEL} DIRECTORY) + get_test_configuration(${PREFIX}) + + set(MODEL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${MODEL}) + + # Copy recipe + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${RECIPE_FILE} + COMMAND ${CMAKE_COMMAND} -E copy "${MODEL_FILE}" + "${CMAKE_CURRENT_BINARY_DIR}/${RECIPE_FILE}" + DEPENDS "${MODEL_FILE}" + COMMENT "Copying ${RECIPE_FILE}") + + # Generate tflitemodel + add_custom_command(OUTPUT ${TFLITEMODEL_FILE} + COMMAND $<TARGET_FILE:tflchef-file> ${RECIPE_FILE} ${TFLITEMODEL_FILE} + DEPENDS tflchef ${CMAKE_CURRENT_BINARY_DIR}/${RECIPE_FILE} + COMMENT "Generating ${TFLITEMODEL_FILE}") + + # Generate C++ code + add_custom_command(OUTPUT ${SOURCE_FILE} ${ASM_FILE} ${BIN_FILE} + COMMAND $<TARGET_FILE:enco-cli> + --frontend $<TARGET_FILE:enco_tflite_frontend> + --frontend-arg ${TFLITEMODEL_FILE} + --backend-arg ${PREFIX} + DEPENDS enco-cli enco_caffe_frontend ${TFLITEMODEL_FILE} + COMMENT "Generating ${SOURCE_FILE}") + set_source_files_properties(${ASM_FILE} PROPERTIES GENERATED TRUE LANGUAGE C) + + list(APPEND CANDIDATES ${PREFIX}) +endforeach(MODEL) + +### +### Inference test +### +if(NOT TARGET ann_ref_static) + return() +endif(NOT TARGET ann_ref_static) + +find_program(H5DIFF h5diff) + +if (NOT H5DIFF) + return() +endif(NOT H5DIFF) + +message(STATUS "Enable enco(tflite) inference test") + +foreach(PREFIX IN ITEMS ${CANDIDATES}) + if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PREFIX}/INFERENCE") + continue() + endif() + + get_test_configuration(${PREFIX}) + + set(BINDER_TARGET enco_tflite_test_${PREFIX}_binder) + + # Compile nnkit binder (from generated C++ code) + add_library(${BINDER_TARGET} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/../binder.cpp ${SOURCE_FILE} ${ASM_FILE}) + target_include_directories(${BINDER_TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + target_link_libraries(${BINDER_TARGET} nnkit_intf_backend) + target_link_libraries(${BINDER_TARGET} ann_api) + target_link_libraries(${BINDER_TARGET} ann_ref_static) + target_link_libraries(${BINDER_TARGET} stdex) + set_target_properties(${BINDER_TARGET} PROPERTIES OUTPUT_NAME ${PREFIX}) + + list(APPEND TESTS ${PREFIX}) +endforeach(PREFIX) + +# Run tests +add_test(NAME enco_test_tflite + COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/runall.sh" + $<TARGET_FILE:nnkit-run> + $<TARGET_FILE:nnkit_tflite_backend> + $<TARGET_FILE:nnkit_randomize_action> + $<TARGET_FILE:nnkit_HDF5_export_action> + $<TARGET_FILE:nnkit_HDF5_import_action> + "${CMAKE_CURRENT_BINARY_DIR}" + ${TESTS}) diff --git a/compiler/enco/test/tflite/Concat_000/INFERENCE b/compiler/enco/test/tflite/Concat_000/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/Concat_000/INFERENCE diff --git a/compiler/enco/test/tflite/Concat_000/test.recipe b/compiler/enco/test/tflite/Concat_000/test.recipe new file mode 100644 index 000000000..35641bd07 --- /dev/null +++ b/compiler/enco/test/tflite/Concat_000/test.recipe @@ -0,0 +1,28 @@ +operand { + name: "ifm1" + type: FLOAT32 + shape { dim: 1 dim: 4 dim: 4 dim: 1 } +} +operand { + name: "ifm2" + type: FLOAT32 + shape { dim: 1 dim: 4 dim: 4 dim: 2 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 4 dim: 4 dim: 3 } +} +operation { + type: "Concatenation" + concatenation_options { + axis: 3 + activation: NONE + } + input: "ifm1" + input: "ifm2" + output: "ofm" +} +input: "ifm1" +input: "ifm2" +output: "ofm" diff --git a/compiler/enco/test/tflite/Concat_001/INFERENCE b/compiler/enco/test/tflite/Concat_001/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/Concat_001/INFERENCE diff --git a/compiler/enco/test/tflite/Concat_001/test.recipe b/compiler/enco/test/tflite/Concat_001/test.recipe new file mode 100644 index 000000000..7adaf1645 --- /dev/null +++ b/compiler/enco/test/tflite/Concat_001/test.recipe @@ -0,0 +1,29 @@ +# Concatenate two feature maps along "width" dimension +operand { + name: "ifm1" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 1 } +} +operand { + name: "ifm2" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 2 dim: 1 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 3 dim: 1 } +} +operation { + type: "Concatenation" + concatenation_options { + axis: 2 + activation: NONE + } + input: "ifm1" + input: "ifm2" + output: "ofm" +} +input: "ifm1" +input: "ifm2" +output: "ofm" diff --git a/compiler/enco/test/tflite/Concat_002/INFERENCE b/compiler/enco/test/tflite/Concat_002/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/Concat_002/INFERENCE diff --git a/compiler/enco/test/tflite/Concat_002/test.recipe b/compiler/enco/test/tflite/Concat_002/test.recipe new file mode 100644 index 000000000..918cb13d3 --- /dev/null +++ b/compiler/enco/test/tflite/Concat_002/test.recipe @@ -0,0 +1,29 @@ +# Concatenate two feature maps along "height" dimension +operand { + name: "ifm1" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 1 } +} +operand { + name: "ifm2" + type: FLOAT32 + shape { dim: 1 dim: 2 dim: 1 dim: 1 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 1 dim: 1 } +} +operation { + type: "Concatenation" + concatenation_options { + axis: 1 + activation: NONE + } + input: "ifm1" + input: "ifm2" + output: "ofm" +} +input: "ifm1" +input: "ifm2" +output: "ofm" diff --git a/compiler/enco/test/tflite/Concat_003/INFERENCE b/compiler/enco/test/tflite/Concat_003/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/Concat_003/INFERENCE diff --git a/compiler/enco/test/tflite/Concat_003/test.recipe b/compiler/enco/test/tflite/Concat_003/test.recipe new file mode 100644 index 000000000..8f1b64ea6 --- /dev/null +++ b/compiler/enco/test/tflite/Concat_003/test.recipe @@ -0,0 +1,29 @@ +# Concatenate two feature maps along "batch" dimension +operand { + name: "ifm1" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 1 } +} +operand { + name: "ifm2" + type: FLOAT32 + shape { dim: 2 dim: 1 dim: 1 dim: 1 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 3 dim: 1 dim: 1 dim: 1 } +} +operation { + type: "Concatenation" + concatenation_options { + axis: 0 + activation: NONE + } + input: "ifm1" + input: "ifm2" + output: "ofm" +} +input: "ifm1" +input: "ifm2" +output: "ofm" diff --git a/compiler/enco/test/tflite/Conv2D_000/INFERENCE b/compiler/enco/test/tflite/Conv2D_000/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/Conv2D_000/INFERENCE diff --git a/compiler/enco/test/tflite/Conv2D_000/test.recipe b/compiler/enco/test/tflite/Conv2D_000/test.recipe new file mode 100644 index 000000000..9f0841819 --- /dev/null +++ b/compiler/enco/test/tflite/Conv2D_000/test.recipe @@ -0,0 +1,45 @@ +# Test for basic case: VALID padding, no activation layer, stride=[1,1] +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } +} +operand { + name: "ker" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 2 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "bias" + type: FLOAT32 + shape { dim: 1 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 1 } +} +operation { + type: "Conv2D" + conv2d_options { + padding: VALID + stride_w: 1 + stride_h: 1 + } + input: "ifm" + input: "ker" + input: "bias" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/enco/test/tflite/Conv2D_001/INFERENCE b/compiler/enco/test/tflite/Conv2D_001/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/Conv2D_001/INFERENCE diff --git a/compiler/enco/test/tflite/Conv2D_001/test.recipe b/compiler/enco/test/tflite/Conv2D_001/test.recipe new file mode 100644 index 000000000..d9d4904da --- /dev/null +++ b/compiler/enco/test/tflite/Conv2D_001/test.recipe @@ -0,0 +1,45 @@ +# Test for SAME padding +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 5 dim: 2 } +} +operand { + name: "ker" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "bias" + type: FLOAT32 + shape { dim: 1 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 5 dim: 1 } +} +operation { + type: "Conv2D" + conv2d_options { + padding: SAME + stride_w: 1 + stride_h: 1 + } + input: "ifm" + input: "ker" + input: "bias" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/enco/test/tflite/Conv2D_002/INFERENCE b/compiler/enco/test/tflite/Conv2D_002/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/Conv2D_002/INFERENCE diff --git a/compiler/enco/test/tflite/Conv2D_002/test.recipe b/compiler/enco/test/tflite/Conv2D_002/test.recipe new file mode 100644 index 000000000..55976c9b9 --- /dev/null +++ b/compiler/enco/test/tflite/Conv2D_002/test.recipe @@ -0,0 +1,46 @@ +# Test for RELU activation layer +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } +} +operand { + name: "ker" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 2 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "bias" + type: FLOAT32 + shape { dim: 1 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 1 } +} +operation { + type: "Conv2D" + conv2d_options { + padding: VALID + stride_w: 1 + stride_h: 1 + activation: RELU + } + input: "ifm" + input: "ker" + input: "bias" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/enco/test/tflite/Conv2D_003/INFERENCE b/compiler/enco/test/tflite/Conv2D_003/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/Conv2D_003/INFERENCE diff --git a/compiler/enco/test/tflite/Conv2D_003/test.recipe b/compiler/enco/test/tflite/Conv2D_003/test.recipe new file mode 100644 index 000000000..30c9473b7 --- /dev/null +++ b/compiler/enco/test/tflite/Conv2D_003/test.recipe @@ -0,0 +1,45 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } +} +operand { + name: "ker" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 2 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "bias" + type: FLOAT32 + shape { dim: 1 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 1 } +} +operation { + type: "Conv2D" + conv2d_options { + padding: VALID + stride_w: 1 + stride_h: 1 + activation: RELU6 + } + input: "ifm" + input: "ker" + input: "bias" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/enco/test/tflite/Conv2D_004/INFERENCE b/compiler/enco/test/tflite/Conv2D_004/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/Conv2D_004/INFERENCE diff --git a/compiler/enco/test/tflite/Conv2D_004/test.recipe b/compiler/enco/test/tflite/Conv2D_004/test.recipe new file mode 100644 index 000000000..20f4a9908 --- /dev/null +++ b/compiler/enco/test/tflite/Conv2D_004/test.recipe @@ -0,0 +1,45 @@ +# Conv2D with ifm w, h = 14, 14 && ofm w, h = 7, 7 && stride = 2, 2 && padding = SAME (similar case from Mobile) +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 14 dim: 14 dim: 2 } +} +operand { + name: "ker" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "bias" + type: FLOAT32 + shape { dim: 1 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 7 dim: 7 dim: 1 } +} +operation { + type: "Conv2D" + conv2d_options { + padding: SAME + stride_w: 2 + stride_h: 2 + } + input: "ifm" + input: "ker" + input: "bias" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/enco/test/tflite/DepthwiseConv2D_000/INFERENCE b/compiler/enco/test/tflite/DepthwiseConv2D_000/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/DepthwiseConv2D_000/INFERENCE diff --git a/compiler/enco/test/tflite/DepthwiseConv2D_000/test.recipe b/compiler/enco/test/tflite/DepthwiseConv2D_000/test.recipe new file mode 100644 index 000000000..27bc767fc --- /dev/null +++ b/compiler/enco/test/tflite/DepthwiseConv2D_000/test.recipe @@ -0,0 +1,48 @@ +# SAME padding, stride = [1,1], activation=RELU6. +# In mobilenet, there are two cases using depthwiseConv2D : A case like this one, and another case with stride=[2,2] +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 5 dim: 5 dim: 4 } +} +operand { + name: "ker" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 4 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "bias" + type: FLOAT32 + shape { dim: 4 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 5 dim: 5 dim: 4 } +} +operation { + type: "DepthwiseConv2D" + depthwiseconv2d_options { + padding: SAME + stride_w: 1 + stride_h: 1 + depth_multiplier: 1 + activation: RELU6 + } + input: "ifm" + input: "ker" + input: "bias" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/enco/test/tflite/DepthwiseConv2D_001/INFERENCE b/compiler/enco/test/tflite/DepthwiseConv2D_001/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/DepthwiseConv2D_001/INFERENCE diff --git a/compiler/enco/test/tflite/DepthwiseConv2D_001/test.recipe b/compiler/enco/test/tflite/DepthwiseConv2D_001/test.recipe new file mode 100644 index 000000000..0166474d8 --- /dev/null +++ b/compiler/enco/test/tflite/DepthwiseConv2D_001/test.recipe @@ -0,0 +1,46 @@ +# depthwiseConv2D with ifm w, h = 14, 14 && ofm w, h = 7, 7 && stride = 2, 2 && padding = SAME (similar case from Mobile) +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 14 dim: 14 dim: 5 } +} +operand { + name: "ker" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 5 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "bias" + type: FLOAT32 + shape { dim: 5 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 7 dim: 7 dim: 5 } +} +operation { + type: "DepthwiseConv2D" + depthwiseconv2d_options { + padding: SAME + stride_w: 2 + stride_h: 2 + activation: RELU6 + } + input: "ifm" + input: "ker" + input: "bias" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/enco/test/tflite/Div_000/INFERENCE b/compiler/enco/test/tflite/Div_000/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/Div_000/INFERENCE diff --git a/compiler/enco/test/tflite/Div_000/test.recipe b/compiler/enco/test/tflite/Div_000/test.recipe new file mode 100644 index 000000000..a6335de46 --- /dev/null +++ b/compiler/enco/test/tflite/Div_000/test.recipe @@ -0,0 +1,27 @@ +operand { + name: "ifm0" + type: FLOAT32 + shape { dim: 1 dim: 4 dim: 4 dim: 3 } +} +operand { + name: "ifm1" + type: FLOAT32 + shape { dim: 1 dim: 4 dim: 4 dim: 3 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 4 dim: 4 dim: 3 } +} +operation { + type: "Div" + input: "ifm0" + input: "ifm1" + output: "ofm" + div_options { + activation: NONE + } +} +input: "ifm0" +input: "ifm1" +output: "ofm" diff --git a/compiler/enco/test/tflite/MaxPool2D_000/INFERENCE b/compiler/enco/test/tflite/MaxPool2D_000/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/MaxPool2D_000/INFERENCE diff --git a/compiler/enco/test/tflite/MaxPool2D_000/test.recipe b/compiler/enco/test/tflite/MaxPool2D_000/test.recipe new file mode 100644 index 000000000..718630f08 --- /dev/null +++ b/compiler/enco/test/tflite/MaxPool2D_000/test.recipe @@ -0,0 +1,24 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 8 dim: 8 dim: 1 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 7 dim: 7 dim: 1 } +} +operation { + type: "MaxPool2D" + maxpool2d_options { + padding: VALID + stride_w: 1 + stride_h: 1 + filter_width: 2 + filter_height: 2 + } + input: "ifm" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/enco/test/tflite/ReLU6_000/INFERENCE b/compiler/enco/test/tflite/ReLU6_000/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/ReLU6_000/INFERENCE diff --git a/compiler/enco/test/tflite/ReLU6_000/test.recipe b/compiler/enco/test/tflite/ReLU6_000/test.recipe new file mode 100644 index 000000000..226593593 --- /dev/null +++ b/compiler/enco/test/tflite/ReLU6_000/test.recipe @@ -0,0 +1,17 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } +} +operation { + type: "ReLU6" + input: "ifm" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/enco/test/tflite/ReLU_000/INFERENCE b/compiler/enco/test/tflite/ReLU_000/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/ReLU_000/INFERENCE diff --git a/compiler/enco/test/tflite/ReLU_000/test.recipe b/compiler/enco/test/tflite/ReLU_000/test.recipe new file mode 100644 index 000000000..8eaa3602f --- /dev/null +++ b/compiler/enco/test/tflite/ReLU_000/test.recipe @@ -0,0 +1,17 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } +} +operation { + type: "ReLU" + input: "ifm" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/enco/test/tflite/Regression_0000/INFERENCE b/compiler/enco/test/tflite/Regression_0000/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/Regression_0000/INFERENCE diff --git a/compiler/enco/test/tflite/Regression_0000/test.recipe b/compiler/enco/test/tflite/Regression_0000/test.recipe new file mode 100644 index 000000000..2f3c03670 --- /dev/null +++ b/compiler/enco/test/tflite/Regression_0000/test.recipe @@ -0,0 +1,84 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 8 dim: 8 dim: 2 } +} +operand { + name: "ker_0" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 2 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "bias_0" + type: FLOAT32 + shape { dim: 1 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "0.1" + } +} +operand { + name: "ofm_0" + type: FLOAT32 + shape { dim: 1 dim: 8 dim: 8 dim: 1 } +} +operation { + type: "Conv2D" + conv2d_options { + padding: VALID + stride_w: 1 + stride_h: 1 + activation: NONE + } + input: "ifm" + input: "ker_0" + input: "bias_0" + output: "ofm_0" +} +operand { + name: "ker_1" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 2 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "bias_1" + type: FLOAT32 + shape { dim: 1 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "0.1" + } +} +operand { + name: "ofm_1" + type: FLOAT32 + shape { dim: 1 dim: 8 dim: 8 dim: 1 } +} +operation { + type: "Conv2D" + conv2d_options { + padding: VALID + stride_w: 1 + stride_h: 1 + activation: NONE + } + input: "ifm" + input: "ker_1" + input: "bias_1" + output: "ofm_1" +} +input: "ifm" +output: "ofm_0" +output: "ofm_1" diff --git a/compiler/enco/test/tflite/Regression_0001/INFERENCE b/compiler/enco/test/tflite/Regression_0001/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/Regression_0001/INFERENCE diff --git a/compiler/enco/test/tflite/Regression_0001/test.recipe b/compiler/enco/test/tflite/Regression_0001/test.recipe new file mode 100644 index 000000000..e6f4eca8f --- /dev/null +++ b/compiler/enco/test/tflite/Regression_0001/test.recipe @@ -0,0 +1,50 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } +} +operand { + name: "ker" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 2 } + filler { tag: "gaussian" arg: "0.0" arg: "1.0" } +} +operand { + name: "bias" + type: FLOAT32 + shape { dim: 1 } + filler { tag: "gaussian" arg: "0.0" arg: "1.0" } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 1 } +} +operand { + name: "arr" + type: FLOAT32 + shape { dim: 1 dim: 9 } +} +operand { + name: "shape" + type: INT32 + shape { dim: 2 } + filler { tag: "explicit" arg: "-1" arg: "9" } +} +operation { + type: "Conv2D" + conv2d_options { padding: VALID stride_w: 1 stride_h: 1 activation: RELU6 } + input: "ifm" + input: "ker" + input: "bias" + output: "ofm" +} +operation { + type: "Reshape" + input: "ofm" + input: "shape" + output: "arr" + reshape_options { new_shape: [-1, 9] } +} +input: "ifm" +output: "arr" diff --git a/compiler/enco/test/tflite/Regression_0002/INFERENCE b/compiler/enco/test/tflite/Regression_0002/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/Regression_0002/INFERENCE diff --git a/compiler/enco/test/tflite/Regression_0002/test.recipe b/compiler/enco/test/tflite/Regression_0002/test.recipe new file mode 100644 index 000000000..8234c7996 --- /dev/null +++ b/compiler/enco/test/tflite/Regression_0002/test.recipe @@ -0,0 +1,45 @@ +# Compilation SHOULD NOT fail even when there is no effective calcualtion +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 8 dim: 8 dim: 2 } +} +operand { + name: "ker" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 2 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "bias" + type: FLOAT32 + shape { dim: 1 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "0.1" + } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 8 dim: 8 dim: 1 } +} +operation { + type: "Conv2D" + conv2d_options { + padding: VALID + stride_w: 1 + stride_h: 1 + activation: NONE + } + input: "ifm" + input: "ker" + input: "bias" + output: "ofm" +} +input: "ifm" diff --git a/compiler/enco/test/tflite/Regression_0003/INFERENCE b/compiler/enco/test/tflite/Regression_0003/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/Regression_0003/INFERENCE diff --git a/compiler/enco/test/tflite/Regression_0003/test.recipe b/compiler/enco/test/tflite/Regression_0003/test.recipe new file mode 100644 index 000000000..693c45543 --- /dev/null +++ b/compiler/enco/test/tflite/Regression_0003/test.recipe @@ -0,0 +1,33 @@ +# Compilation SHOULD NOT fail even if all the inputs are constant +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } + filler { tag: "constant" arg: "0.1" } +} +operand { + name: "ker" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 2 } + filler { tag: "constant" arg: "0.2" } +} +operand { + name: "bias" + type: FLOAT32 + shape { dim: 1 } + filler { tag: "constant" arg: "0.3" } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 1 } +} +operation { + type: "Conv2D" + conv2d_options { padding: VALID } + input: "ifm" + input: "ker" + input: "bias" + output: "ofm" +} +output: "ofm" diff --git a/compiler/enco/test/tflite/Regression_0004/INFERENCE b/compiler/enco/test/tflite/Regression_0004/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/Regression_0004/INFERENCE diff --git a/compiler/enco/test/tflite/Regression_0004/test.recipe b/compiler/enco/test/tflite/Regression_0004/test.recipe new file mode 100644 index 000000000..80705efd5 --- /dev/null +++ b/compiler/enco/test/tflite/Regression_0004/test.recipe @@ -0,0 +1,27 @@ +operand { + name: "ifm0" + type: FLOAT32 + shape { dim: 1 dim: 4 dim: 4 dim: 3 } + filler { tag: "constant" arg: "0.1" } +} +operand { + name: "ifm1" + type: FLOAT32 + shape { dim: 1 dim: 4 dim: 4 dim: 3 } + filler { tag: "constant" arg: "0.1" } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 4 dim: 4 dim: 3 } +} +operation { + type: "Div" + input: "ifm0" + input: "ifm1" + output: "ofm" + div_options { + activation: NONE + } +} +output: "ofm" diff --git a/compiler/enco/test/tflite/Reshape_000/INFERENCE b/compiler/enco/test/tflite/Reshape_000/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/Reshape_000/INFERENCE diff --git a/compiler/enco/test/tflite/Reshape_000/test.recipe b/compiler/enco/test/tflite/Reshape_000/test.recipe new file mode 100644 index 000000000..bb7ce48a9 --- /dev/null +++ b/compiler/enco/test/tflite/Reshape_000/test.recipe @@ -0,0 +1,21 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 10 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 10 } +} +operation { + type: "Reshape" + reshape_options { + new_shape: -1 + new_shape: 10 + } + input: "ifm" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/enco/test/tflite/Sub_000/INFERENCE b/compiler/enco/test/tflite/Sub_000/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/Sub_000/INFERENCE diff --git a/compiler/enco/test/tflite/Sub_000/test.recipe b/compiler/enco/test/tflite/Sub_000/test.recipe new file mode 100644 index 000000000..0397c9c2b --- /dev/null +++ b/compiler/enco/test/tflite/Sub_000/test.recipe @@ -0,0 +1,27 @@ +operand { + name: "ifm1" + type: FLOAT32 + shape { dim: 1 dim: 5 dim:2 dim:3 } +} +operand { + name: "ifm2" + type: FLOAT32 + shape { dim: 1 dim: 5 dim:2 dim:3 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 5 dim:2 dim:3 } +} +operation { + type: "Sub" + sub_options { + activation: NONE + } + input: "ifm1" + input: "ifm2" + output: "ofm" +} +input: "ifm1" +input: "ifm2" +output: "ofm" diff --git a/compiler/enco/test/tflite/empty/INFERENCE b/compiler/enco/test/tflite/empty/INFERENCE new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/empty/INFERENCE diff --git a/compiler/enco/test/tflite/empty/test.recipe b/compiler/enco/test/tflite/empty/test.recipe new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/enco/test/tflite/empty/test.recipe diff --git a/compiler/enco/test/tflite/runall.sh b/compiler/enco/test/tflite/runall.sh new file mode 100755 index 000000000..c274f724b --- /dev/null +++ b/compiler/enco/test/tflite/runall.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +if [[ $# -le 6 ]]; then + echo "USAGE: $0 [nnkit-run path] [reference backend path] [randomize action path] [HDF5 export action path] [HDF5 import action path] [WORKDIR] [Prefix1] [Prefix2] ..." + exit 255 +fi + +NNKIT_RUN_PATH="$1"; shift +REFERENCE_BACKEND_PATH="$1"; shift +RANDOMIZE_ACTION_PATH="$1"; shift +HDF5_EXPORT_ACTION_PATH="$1"; shift +HDF5_IMPORT_ACTION_PATH="$1"; shift +WORKDIR="$1"; shift + +echo "-- Found nnkit-run: ${NNKIT_RUN_PATH}" +echo "-- Found reference backend: ${REFERENCE_BACKEND_PATH}" +echo "-- Found randomize action: ${RANDOMIZE_ACTION_PATH}" +echo "-- Found HDF5 export action: ${HDF5_EXPORT_ACTION_PATH}" +echo "-- Found HDF5 import action: ${HDF5_IMPORT_ACTION_PATH}" +echo "-- Found workdir: ${WORKDIR}" + +TESTED=() +PASSED=() +FAILED=() + +pushd "${WORKDIR}" +while [[ $# -ne 0 ]]; do + PREFIX="$1"; shift + + TESTED+=("${PREFIX}") + + PASSED_TAG="${PREFIX}.passed" + + rm -f "${PASSED_TAG}" + + cat > "${PREFIX}.log" <( + exec 2>&1 + + echo "-- Found tflite: ${PREFIX}.tflite" + echo "-- Found backend: lib${PREFIX}.so" + + "${NNKIT_RUN_PATH}" \ + --backend "${REFERENCE_BACKEND_PATH}" \ + --backend-arg "${WORKDIR}/${PREFIX}.tflite" \ + --pre "${RANDOMIZE_ACTION_PATH}" \ + --pre "${HDF5_EXPORT_ACTION_PATH}" \ + --pre-arg "${PREFIX}.input.h5" \ + --post "${HDF5_EXPORT_ACTION_PATH}" \ + --post-arg "${PREFIX}.expected.h5" + + "${NNKIT_RUN_PATH}" \ + --backend "./lib${PREFIX}.so" \ + --pre "${HDF5_IMPORT_ACTION_PATH}" \ + --pre-arg "${PREFIX}.input.h5" \ + --post "${HDF5_EXPORT_ACTION_PATH}" \ + --post-arg "${PREFIX}.obtained.h5" + + h5diff -d 0.001 "${PREFIX}.expected.h5" "${PREFIX}.obtained.h5" + + if [[ $? -eq 0 ]]; then + touch "${PASSED_TAG}" + fi + ) + + if [[ -f "${PASSED_TAG}" ]]; then + PASSED+=("$PREFIX") + else + FAILED+=("$PREFIX") + fi +done +popd + +if [[ ${#TESTED[@]} -ne ${#PASSED[@]} ]]; then + echo "FAILED" + for TEST in "${FAILED[@]}" + do + echo "- ${TEST}" + done + exit 255 +fi + +echo "PASSED" +exit 0 |