File tree Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Copyright (c) ONNX Project Contributors
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ name : Build and Test
6
+
7
+ on :
8
+ push :
9
+ branches :
10
+ - main
11
+ pull_request :
12
+ workflow_dispatch :
13
+
14
+ jobs :
15
+ build_and_test :
16
+ runs-on : ubuntu-24.04
17
+ steps :
18
+ - uses : actions/checkout@v4
19
+ with :
20
+ submodules : recursive
21
+ - run : cmake -GNinja -DONNX_BUILD_TESTS=ON -B build -S .
22
+ - run : cmake --build build
23
+ - run : cmake --build build -t test
Original file line number Diff line number Diff line change @@ -98,3 +98,10 @@ install(TARGETS
98
98
onnx_optimizer onnx_optimizer_c_api
99
99
EXPORT ONNXOptimizerTargets DESTINATION ${CMAKE_INSTALL_LIBDIR} )
100
100
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 onnx_optimizer gtest gtest_main )
106
+ add_test (NAME test_simple COMMAND ${CMAKE_CURRENT_BINARY_DIR} /test_simple )
107
+ endif ()
Original file line number Diff line number Diff line change
1
+ #include < gtest/gtest.h>
2
+ #include < onnxoptimizer/optimize.h>
3
+ #include < onnx/defs/parser.h>
4
+
5
+ TEST (OptimizerTest, NopReshape) {
6
+ const char * graph_str = R"(
7
+ <
8
+ ir_version: 7,
9
+ opset_import: [ "": 10]
10
+ >
11
+ agraph (float[5, 7] X) => (float[5, 7] Z)
12
+ {
13
+ Shape = Constant<value=int64[2]{5, -1}> ()
14
+ Y = Reshape (X, Shape)
15
+ Z = Identity(Y)
16
+ }
17
+ )" ;
18
+ onnx::ModelProto model;
19
+ const onnx::Status status = onnx::OnnxParser::Parse (model, graph_str);
20
+ EXPECT_TRUE (status.IsOK ());
21
+ auto optimized_model = onnx::optimization::Optimize (model, {" eliminate_nop_reshape" , " eliminate_deadend" });
22
+
23
+ ASSERT_EQ (optimized_model.graph ().node ().size (), 1 );
24
+ ASSERT_EQ (optimized_model.graph ().node ()[0 ].op_type (), " Identity" );
25
+ }
You can’t perform that action at this time.
0 commit comments