From af9929fda90f06890126288516736630daf7b22f Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=82=A8=EA=B6=81=EC=84=9D/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Tue, 30 Apr 2019 07:31:23 +0900 Subject: [PATCH] [moco/ONNX] Introduce Identity testcase for moco ONNX frontend (#3380) This commit will introduce a new testcase for moco ONNX frontend, which is consisted of Identity operation. Signed-off-by: Seok NamKoong --- contrib/moco/test/CMakeLists.txt | 1 + contrib/moco/test/onnx/CMakeLists.txt | 40 ++++++++++++++++ contrib/moco/test/onnx/Identity_000/test.pbtxt | 64 ++++++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 contrib/moco/test/onnx/CMakeLists.txt create mode 100644 contrib/moco/test/onnx/Identity_000/test.pbtxt diff --git a/contrib/moco/test/CMakeLists.txt b/contrib/moco/test/CMakeLists.txt index 313963d..f287a25 100644 --- a/contrib/moco/test/CMakeLists.txt +++ b/contrib/moco/test/CMakeLists.txt @@ -1 +1,2 @@ add_subdirectory(tf) +add_subdirectory(onnx) diff --git a/contrib/moco/test/onnx/CMakeLists.txt b/contrib/moco/test/onnx/CMakeLists.txt new file mode 100644 index 0000000..1d50c47 --- /dev/null +++ b/contrib/moco/test/onnx/CMakeLists.txt @@ -0,0 +1,40 @@ +option(MOCO_ONNX_TEST "Enable moco test for ONNX" ON) + +if(NOT MOCO_ONNX_TEST) + return() +endif(NOT MOCO_ONNX_TEST) + +if(NOT TARGET onnxkit) + message(STATUS "moco: 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") + +file(GLOB PBTXTFILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/${TEST_PBTXT_FILE}") + +foreach(PBTXTFILE IN ITEMS ${PBTXTFILES}) + get_filename_component(DIR_NAME ${PBTXTFILE} DIRECTORY) + + set(PBTXT_SOURCE_FILE "${DIR_NAME}.pbtxt") + set(PBTXT_SOURCE_TARGET moco_onnx_${DIR_NAME}_pbtxt) + + set(PB_OUTPUT_FILE "${DIR_NAME}.pb") + set(PB_OUTPUT_TARGET moco_onnx_${DIR_NAME}_pb) + + # Copy files + add_custom_target(${PBTXT_SOURCE_TARGET} + ALL ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${PBTXTFILE}" + "${CMAKE_CURRENT_BINARY_DIR}/${PBTXT_SOURCE_FILE}" + COMMENT "Copy ${PBTXT_SOURCE_FILE}") + + # Use onnxkit to encode + add_custom_target(${PB_OUTPUT_TARGET} + ALL $ encode ${PBTXT_SOURCE_FILE} ${PB_OUTPUT_FILE} + DEPENDS ${PBTXT_SOURCE_TARGET} + COMMENT "Generate ${PB_OUTPUT_FILE}") +endforeach(PBTXTFILE) diff --git a/contrib/moco/test/onnx/Identity_000/test.pbtxt b/contrib/moco/test/onnx/Identity_000/test.pbtxt new file mode 100644 index 0000000..e8bcafb --- /dev/null +++ b/contrib/moco/test/onnx/Identity_000/test.pbtxt @@ -0,0 +1,64 @@ +# IR version : https://github.com/onnx/onnx/blob/master/onnx/onnx.proto3#L57 +ir_version: 5 + +# Opset version : https://github.com/onnx/onnx/blob/master/onnx/defs/operator_sets.h +opset_import { + version: 10 +} + +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 + } + } + } + } + } +} -- 2.7.4