Skip to content

Commit 896562e

Browse files
committed
[WIP] Add C++ test
Signed-off-by: take-cheeze <[email protected]>
1 parent 5094dcf commit 896562e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,10 @@ install(TARGETS
9898
onnx_optimizer onnx_optimizer_c_api
9999
EXPORT ONNXOptimizerTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})
100100

101+
if(ONNX_BUILD_TESTS)
102+
enable_testing()
103+
include(third_party/onnx/cmake/external/googletest.cmake)
104+
add_executable(test_simple tests/test_simple.cc)
105+
target_link_libraries(test_simple gtest)
106+
add_test(NAME test_simple COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_simple)
107+
endif()

tests/test_simple.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <gtest/gtest.h>
2+
3+
TEST(OptimizerTest, NopReshape) {
4+
Graph graph = parser.parse_graph(R"(
5+
agraph (float[5, 7] X) => (float[5, 7] Z)
6+
{
7+
Shape = Constant<value=int64[2]{5, -1}> ()
8+
Y = Reshape (X, Shape)
9+
Z = Identity(Y)
10+
}
11+
)");
12+
OptimizedModel optimized_model = _optimized(graph, {"eliminate_nop_reshape", "eliminate_deadend"}, false);
13+
14+
ASSERT_EQ(optimized_model.graph.node.size(), 1);
15+
ASSERT_EQ(optimized_model.graph.node[0].op_type, "Identity");
16+
}

0 commit comments

Comments
 (0)