diff --git a/src/nnfusion/core/operators/generic_op/generic_op_define/Scatter.cpp b/src/nnfusion/core/operators/generic_op/generic_op_define/Scatter.cpp index af0bfb16..2124523a 100644 --- a/src/nnfusion/core/operators/generic_op/generic_op_define/Scatter.cpp +++ b/src/nnfusion/core/operators/generic_op/generic_op_define/Scatter.cpp @@ -32,4 +32,4 @@ REGISTER_SCATTER_OP(ScatterSub) REGISTER_SCATTER_OP(ScatterAdd) REGISTER_SCATTER_OP(ScatterMax) -REGISTER_SCATTER_OP(ScatterMim) \ No newline at end of file +REGISTER_SCATTER_OP(ScatterMin) \ No newline at end of file diff --git a/test/models/tensorflow/frozen_op_graph/frozen_scatteradd_graph.pb b/test/models/tensorflow/frozen_op_graph/frozen_scatteradd_graph.pb new file mode 100644 index 00000000..b73d3f91 Binary files /dev/null and b/test/models/tensorflow/frozen_op_graph/frozen_scatteradd_graph.pb differ diff --git a/test/models/tensorflow/frozen_op_graph/frozen_scattermax_graph.pb b/test/models/tensorflow/frozen_op_graph/frozen_scattermax_graph.pb new file mode 100644 index 00000000..c02b8c7d Binary files /dev/null and b/test/models/tensorflow/frozen_op_graph/frozen_scattermax_graph.pb differ diff --git a/test/models/tensorflow/frozen_op_graph/frozen_scattermin_graph.pb b/test/models/tensorflow/frozen_op_graph/frozen_scattermin_graph.pb new file mode 100644 index 00000000..a7db503f Binary files /dev/null and b/test/models/tensorflow/frozen_op_graph/frozen_scattermin_graph.pb differ diff --git a/test/models/tensorflow/frozen_op_graph/frozen_scattersub_graph.pb b/test/models/tensorflow/frozen_op_graph/frozen_scattersub_graph.pb old mode 100755 new mode 100644 index b566668a..a02bbef1 Binary files a/test/models/tensorflow/frozen_op_graph/frozen_scattersub_graph.pb and b/test/models/tensorflow/frozen_op_graph/frozen_scattersub_graph.pb differ diff --git a/test/nnfusion/frontend/tensorflow_import.cpp b/test/nnfusion/frontend/tensorflow_import.cpp index f5620ce1..57d6b449 100644 --- a/test/nnfusion/frontend/tensorflow_import.cpp +++ b/test/nnfusion/frontend/tensorflow_import.cpp @@ -551,13 +551,61 @@ TEST(nnfusion_tensorflow_import, sigmoid_op) } } +TEST(nnfusion_tensorflow_import, scatteradd_op) +{ + auto model = frontend::load_tensorflow_model(file_util::path_join( + SERIALIZED_ZOO, "tensorflow/frozen_op_graph/frozen_scatteradd_graph.pb")); + + Inputs inputs{test::NDArray{{1, 1}, {1, 1}, {-1, -4}, {0, 1}}.get_vector()}; + Outputs expected_outputs{{0, 0, 2, 3, 0, -1, 1, 1}}; + + Outputs outputs{execute(model, inputs, "NNFusion")}; + EXPECT_EQ(outputs.size(), expected_outputs.size()); + for (std::size_t i = 0; i < expected_outputs.size(); ++i) + { + EXPECT_EQ(expected_outputs[i], outputs[i]); + } +} + TEST(nnfusion_tensorflow_import, scattersub_op) { auto model = frontend::load_tensorflow_model(file_util::path_join( SERIALIZED_ZOO, "tensorflow/frozen_op_graph/frozen_scattersub_graph.pb")); - Inputs inputs{}; - Outputs expected_outputs{{1, 1, 1, 1, -3, -9, -1, 1}}; + Inputs inputs{test::NDArray{{1, 1}, {1, 1}, {-1, -4}, {0, 1}}.get_vector()}; + Outputs expected_outputs{{2, 2, 0, -1, -2, -7, -1, 1}}; + + Outputs outputs{execute(model, inputs, "NNFusion")}; + EXPECT_EQ(outputs.size(), expected_outputs.size()); + for (std::size_t i = 0; i < expected_outputs.size(); ++i) + { + EXPECT_EQ(expected_outputs[i], outputs[i]); + } +} + +TEST(nnfusion_tensorflow_import, scattermax_op) +{ + auto model = frontend::load_tensorflow_model(file_util::path_join( + SERIALIZED_ZOO, "tensorflow/frozen_op_graph/frozen_scattermax_graph.pb")); + + Inputs inputs{test::NDArray{{1, 1}, {1, 1}, {-1, -4}, {0, 1}}.get_vector()}; + Outputs expected_outputs{{1, 1, 1, 2, 1, 3, 1, 1}}; + + Outputs outputs{execute(model, inputs, "NNFusion")}; + EXPECT_EQ(outputs.size(), expected_outputs.size()); + for (std::size_t i = 0; i < expected_outputs.size(); ++i) + { + EXPECT_EQ(expected_outputs[i], outputs[i]); + } +} + +TEST(nnfusion_tensorflow_import, scattermin_op) +{ + auto model = frontend::load_tensorflow_model(file_util::path_join( + SERIALIZED_ZOO, "tensorflow/frozen_op_graph/frozen_scattermin_graph.pb")); + + Inputs inputs{test::NDArray{{1, 1}, {1, 1}, {-1, -4}, {0, 1}}.get_vector()}; + Outputs expected_outputs{{-1, -1, 1, 1, -1, -4, 0, 0}}; Outputs outputs{execute(model, inputs, "NNFusion")}; EXPECT_EQ(outputs.size(), expected_outputs.size());