From ccdc22613e36ca2e554d4f9f19211d1ee6ea29bf Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=B2=9C=EA=B5=90/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Tue, 5 Nov 2019 09:25:01 +0900 Subject: [PATCH] Introduce oneco-value-pbtxt-test (#8737) This commit introduces oneco value test for pbtxt input model. It copies existing oneco-integration-test only with renaming. Signed-off-by: Cheongyo Bahk --- compiler/oneco-value-pbtxt-test/CMakeLists.txt | 53 +++++++++++++++++ .../oneco-value-pbtxt-test/Const_000/test.pbtxt | 52 +++++++++++++++++ .../oneco-value-pbtxt-test/Identity_000/test.pbtxt | 66 ++++++++++++++++++++++ compiler/oneco-value-pbtxt-test/requires.cmake | 1 + 4 files changed, 172 insertions(+) create mode 100644 compiler/oneco-value-pbtxt-test/CMakeLists.txt create mode 100644 compiler/oneco-value-pbtxt-test/Const_000/test.pbtxt create mode 100644 compiler/oneco-value-pbtxt-test/Identity_000/test.pbtxt create mode 100644 compiler/oneco-value-pbtxt-test/requires.cmake diff --git a/compiler/oneco-value-pbtxt-test/CMakeLists.txt b/compiler/oneco-value-pbtxt-test/CMakeLists.txt new file mode 100644 index 0000000..6d9563f --- /dev/null +++ b/compiler/oneco-value-pbtxt-test/CMakeLists.txt @@ -0,0 +1,53 @@ +option(ONECO_VALUE_PBTXT_TEST "Enable oneco value test for pbtxt input model" ON) + +if(NOT ONECO_VALUE_PBTXT_TEST) + return() +endif(NOT ONECO_VALUE_PBTXT_TEST) + +if(NOT TARGET onnxkit) + message(STATUS "oneco: Skip test material preparation as onnxkit is not defined") + return() +endif(NOT TARGET onnxkit) + +# +# Copy [Testcase]/test.pbtxt to Testcase.pbtxt in binary folder +# Encode Testcase.pbtxt to Testcase.pb +# +set(TEST_PBTXT_FILE "test.pbtxt") +set(TEST_REPO "${CMAKE_CURRENT_SOURCE_DIR}") # Where to find tests +set(TEST_SPACE "${CMAKE_CURRENT_BINARY_DIR}") # Where to run tests + +file(GLOB PBTXTFILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/${TEST_PBTXT_FILE}") + +unset(TEST_DEPS) + +foreach(PBTXTFILE IN ITEMS ${PBTXTFILES}) + get_filename_component(DIR_NAME ${PBTXTFILE} DIRECTORY) + + set(PBTXT_SOURCE_FILE "${DIR_NAME}.pbtxt") + set(PBTXT_SOURCE_PATH "${TEST_SPACE}/${PBTXT_SOURCE_FILE}") + + set(PB_OUTPUT_FILE "${DIR_NAME}.pb") + set(PB_OUTPUT_PATH "${TEST_SPACE}/${PB_OUTPUT_FILE}") + + # Copy files + add_custom_command( + OUTPUT ${PBTXT_SOURCE_PATH} + COMMAND ${CMAKE_COMMAND} -E copy "${TEST_REPO}/${PBTXTFILE}" "${PBTXT_SOURCE_PATH}" + COMMENT "Copy ${PBTXT_SOURCE_FILE}" + DEPENDS "${TEST_REPO}/${PBTXTFILE}" + ) + + # Use onnxkit to encode + add_custom_command( + OUTPUT ${PB_OUTPUT_PATH} + COMMAND $ encode ${PBTXT_SOURCE_PATH} ${PB_OUTPUT_PATH} + DEPENDS ${PBTXT_SOURCE_PATH} + COMMENT "Generate ${PB_OUTPUT_FILE}" + ) + + list(APPEND TEST_DEPS "${PB_OUTPUT_PATH}") +endforeach(PBTXTFILE) + +# This target enforces CMake to generate all the dependencies during "build" phase +add_custom_target(oneco_value_pbtxt_test_deps ALL DEPENDS ${TEST_DEPS}) diff --git a/compiler/oneco-value-pbtxt-test/Const_000/test.pbtxt b/compiler/oneco-value-pbtxt-test/Const_000/test.pbtxt new file mode 100644 index 0000000..c5ae298 --- /dev/null +++ b/compiler/oneco-value-pbtxt-test/Const_000/test.pbtxt @@ -0,0 +1,52 @@ +# Latest IR_VERSION of 1.4.1 version is 4 +# https://github.com/onnx/onnx/blob/rel-1.4.1/onnx/onnx.proto3 +ir_version: 4 + +# Opset version of IR_VERSION 4 is 9 +# https://github.com/onnx/onnx/blob/rel-1.4.1/onnx/defs/operator_sets.h +opset_import { + version: 9 +} + +graph { + name: "Const_000" + + node { + name: "const_node" + output: "output:0" + op_type: "Constant" + attribute { + name: "const/value" + t { + dims: 2 + dims: 3 + data_type: 1 # FLOAT type + float_data: 1.1 + float_data: 2.2 + float_data: 3.3 + float_data: 4.4 + float_data: 5.5 + float_data: 6.6 + name: "const_tensor" + } + type: TENSOR + } + } + + output { + name: "output:0" + type { + tensor_type { + elem_type: 1 # FLOAT type + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 3 + } + } + } + } + } +} diff --git a/compiler/oneco-value-pbtxt-test/Identity_000/test.pbtxt b/compiler/oneco-value-pbtxt-test/Identity_000/test.pbtxt new file mode 100644 index 0000000..e8aff1d --- /dev/null +++ b/compiler/oneco-value-pbtxt-test/Identity_000/test.pbtxt @@ -0,0 +1,66 @@ +# Latest IR_VERSION of 1.4.1 version is 4 +# https://github.com/onnx/onnx/blob/rel-1.4.1/onnx/onnx.proto3 +ir_version: 4 + +# Opset version of IR_VERSION 4 is 9 +# https://github.com/onnx/onnx/blob/rel-1.4.1/onnx/defs/operator_sets.h +opset_import { + version: 9 +} + +graph { + name: "Identity_000" + + node { + input: "input:0" + output: "output:0" + name: "identity_node" + op_type: "Identity" + } + + input { + name: "input:0" + type { + tensor_type { + elem_type: 1 # FLOAT type + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + } + } + } + } + + output { + name: "output:0" + type { + tensor_type { + elem_type: 1 # FLOAT type + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + } + } + } + } +} diff --git a/compiler/oneco-value-pbtxt-test/requires.cmake b/compiler/oneco-value-pbtxt-test/requires.cmake new file mode 100644 index 0000000..0f21fa9 --- /dev/null +++ b/compiler/oneco-value-pbtxt-test/requires.cmake @@ -0,0 +1 @@ +require("onnxkit") -- 2.7.4