diff --git a/CMakeLists.txt b/CMakeLists.txt index b23e70e68..a26431885 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -248,7 +248,7 @@ if (NOT USE_PRE_BUILT_NGRAPH) ExternalProject_Add( ext_ngraph GIT_REPOSITORY https://github.com/NervanaSystems/ngraph - GIT_TAG v0.25.1-rc.9 + GIT_TAG v0.25.1-rc.10 CMAKE_ARGS -DNGRAPH_DISTRIBUTED_ENABLE=${NGRAPH_DISTRIBUTED_ENABLE} -DNGRAPH_INSTALL_PREFIX=${NGRAPH_ARTIFACTS_DIR} diff --git a/bazel/WORKSPACE b/bazel/WORKSPACE index 9675b0e3f..7b564a924 100644 --- a/bazel/WORKSPACE +++ b/bazel/WORKSPACE @@ -55,11 +55,11 @@ tf_workspace(path_prefix = "", tf_repo_name = "org_tensorflow") http_archive( name = "ngraph", build_file = "//:bazel/ngraph.BUILD", - sha256 = "bb9effe71818d932dfa1f024051ba716267ca1b2fc35471faf780f7bfdf6c9b3", - strip_prefix = "ngraph-0.25.1-rc.9", + sha256 = "110b4f40033ea28425a3b80bc0cb81a0301f5cc0bb92c200f113dfeb9533aec7", + strip_prefix = "ngraph-0.25.1-rc.10", urls = [ - "https://mirror.bazel.build/github.com/NervanaSystems/ngraph/archive/v0.25.1-rc.9.tar.gz", - "https://github.com/NervanaSystems/ngraph/archive/v0.25.1-rc.9.tar.gz" + "https://mirror.bazel.build/github.com/NervanaSystems/ngraph/archive/v0.25.1-rc.10.tar.gz", + "https://github.com/NervanaSystems/ngraph/archive/v0.25.1-rc.10.tar.gz" ], ) diff --git a/bazel/ngraph.BUILD b/bazel/ngraph.BUILD index b8499c29f..ab8a93316 100644 --- a/bazel/ngraph.BUILD +++ b/bazel/ngraph.BUILD @@ -85,7 +85,7 @@ cc_library( "-fstack-protector-all", '-D SHARED_LIB_PREFIX=\\"lib\\"', '-D SHARED_LIB_SUFFIX=\\".so\\"', - '-D NGRAPH_VERSION=\\"v0.25.1-rc.9\\"', + '-D NGRAPH_VERSION=\\"v0.25.1-rc.10\\"', "-D NGRAPH_DEX_ONLY", '-D PROJECT_ROOT_DIR=\\"\\"', '-D NGRAPH_STATIC_LIB_ENABLE' @@ -118,7 +118,7 @@ cc_library( "-fstack-protector-all", '-D SHARED_LIB_PREFIX=\\"lib\\"', '-D SHARED_LIB_SUFFIX=\\".so\\"', - '-D NGRAPH_VERSION=\\"v0.25.1-rc.9\\"', + '-D NGRAPH_VERSION=\\"v0.25.1-rc.10\\"', "-D NGRAPH_DEX_ONLY", '-D PROJECT_ROOT_DIR=\\"\\"', ] + CXX_ABI, @@ -269,7 +269,7 @@ cc_library( "-fstack-protector-all", '-D SHARED_LIB_PREFIX=\\"lib\\"', '-D SHARED_LIB_SUFFIX=\\".so\\"', - '-D NGRAPH_VERSION=\\"0.25.1-rc.9\\"', + '-D NGRAPH_VERSION=\\"0.25.1-rc.10\\"', "-D NGRAPH_DEX_ONLY", '-D PROJECT_ROOT_DIR=\\"\\"', '-D NGRAPH_CPU_STATIC_LIB_ENABLE' diff --git a/build_ngtf.py b/build_ngtf.py index c87a04679..b72b42331 100755 --- a/build_ngtf.py +++ b/build_ngtf.py @@ -53,7 +53,7 @@ def main(): ''' # Component versions - ngraph_version = "v0.25.1-rc.9" + ngraph_version = "v0.25.1-rc.10" tf_version = "v1.14.0" # Command line parser options diff --git a/ngraph_bridge/ngraph_builder.cc b/ngraph_bridge/ngraph_builder.cc index f7c5ba686..f2c828128 100644 --- a/ngraph_bridge/ngraph_builder.cc +++ b/ngraph_bridge/ngraph_builder.cc @@ -3742,6 +3742,34 @@ static Status TranslateRsqrtOp( }); } +static Status TranslateScatterNdOp( + const Node* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + shared_ptr ng_indices; + shared_ptr ng_updates; + TF_RETURN_IF_ERROR( + GetInputNodes(ng_op_map, op, &ng_indices, &ng_updates, nullptr)); + + std::vector ng_shape; + TF_RETURN_IF_ERROR(GetStaticInputVector(op, 2, static_input_map, &ng_shape)); + // Copy the int vector to a size_t vector, because that is what ng::Shape + // accepts + std::vector ng_shape_size_t(ng_shape.begin(), ng_shape.end()); + + // Create a tensor and populate the tensor with "0" to Add to ScatterNd + auto et = ng_updates->get_element_type(); + std::vector constant_values(ng::shape_size(ng_shape_size_t), + "0"); + auto ng_inputs = ConstructNgNode( + op->name(), et, ng::Shape(ng_shape_size_t), constant_values); + + SaveNgOp(ng_op_map, op->name(), + ConstructNgNode(op->name(), ng_inputs, + ng_indices, ng_updates)); + + return Status::OK(); +} + static Status TranslateRsqrtGradOp(const Node* op, const std::vector&, Builder::OpMap& ng_op_map) { @@ -5025,8 +5053,9 @@ const static std::map< {"ReluGrad", TranslateReluGradOp}, {"Reshape", TranslateReshapeOp}, {"ResizeBilinear", TranslateResizeBilinearOp}, {"Rsqrt", TranslateRsqrtOp}, {"RsqrtGrad", TranslateRsqrtGradOp}, - {"Select", TranslateSelectOp}, {"Shape", TranslateShapeOp}, - {"Sigmoid", TranslateSigmoidOp}, {"SigmoidGrad", TranslateSigmoidGradOp}, + {"ScatterNd", TranslateScatterNdOp}, {"Select", TranslateSelectOp}, + {"Shape", TranslateShapeOp}, {"Sigmoid", TranslateSigmoidOp}, + {"SigmoidGrad", TranslateSigmoidGradOp}, {"Sin", TranslateUnaryOp}, {"Size", TranslateSizeOp}, {"Sign", TranslateUnaryOp}, {"Slice", TranslateSliceOp}, {"Snapshot", TranslateIdentityOp}, {"Softmax", TranslateSoftmaxOp}, diff --git a/ngraph_bridge/ngraph_mark_for_clustering.cc b/ngraph_bridge/ngraph_mark_for_clustering.cc index bcd549205..011502d5a 100644 --- a/ngraph_bridge/ngraph_mark_for_clustering.cc +++ b/ngraph_bridge/ngraph_mark_for_clustering.cc @@ -371,6 +371,7 @@ Status MarkForClustering(Graph* graph, const std::set skip_these_nodes, SimpleConfirmationFunction(); confirmation_function_map["Rsqrt"] = SimpleConfirmationFunction(); confirmation_function_map["RsqrtGrad"] = SimpleConfirmationFunction(); + confirmation_function_map["ScatterNd"] = SimpleConfirmationFunction(); confirmation_function_map["Select"] = SimpleConfirmationFunction(); confirmation_function_map["Shape"] = SimpleConfirmationFunction(); confirmation_function_map["Sigmoid"] = SimpleConfirmationFunction(); @@ -568,6 +569,8 @@ Status MarkForClustering(Graph* graph, const std::set skip_these_nodes, type_constraint_map["ResizeBilinear"]["T"] = NGraphNumericDTypes(); type_constraint_map["Rsqrt"]["T"] = NGraphDTypes(); type_constraint_map["RsqrtGrad"]["T"] = NGraphRealDTypes(); + type_constraint_map["ScatterNd"]["T"] = NGraphDTypes(); + type_constraint_map["ScatterNd"]["Tindices"] = NGraphIndexDTypes(); type_constraint_map["Select"]["T"] = NGraphDTypes(); type_constraint_map["Shape"]["T"] = NGraphDTypes(); type_constraint_map["Shape"]["out_type"] = NGraphIndexDTypes(); @@ -651,6 +654,7 @@ Status MarkForClustering(Graph* graph, const std::set skip_these_nodes, return Status::OK(); }; set_attributes_map["Reshape"] = SetStaticInputs({1}); + set_attributes_map["ScatterNd"] = SetStaticInputs({2}); set_attributes_map["Slice"] = SetStaticInputs({1, 2}); set_attributes_map["Split"] = SetStaticInputs({0}); set_attributes_map["SplitV"] = SetStaticInputs({1, 2}); diff --git a/test/python/tensorflow/python_tests_list.txt b/test/python/tensorflow/python_tests_list.txt index 4432ba54f..294107d0e 100644 --- a/test/python/tensorflow/python_tests_list.txt +++ b/test/python/tensorflow/python_tests_list.txt @@ -397,6 +397,76 @@ relu_op_test.ReluTest.testGradientFloat32 relu_op_test.ReluTest.testGradientFloat64 relu_op_test.ReluTest.testGradientScalar +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testBool +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testEmptyOutputShape1 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testEmptyOutputShape2 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testEmptyOutputShape3 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testExtraIndicesDimensions +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testGradientsRank2ElementUpdate +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testGradientsRank2SliceUpdate +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testGradientsRank3SliceUpdate +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testGradientsRank7SliceUpdate +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testInvalidShape +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testRank3InvalidShape1 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testRank3InvalidShape2 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testRank3ValidShape +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testScatterNdRepatedIndicesAdd +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testSmokeScatterNdBatch1DSliceDim2 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testSmokeScatterNdBatch1DSliceDim3ShapeRank7 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testSmokeScatterNdBatch2DSliceDim2 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testSmokeScatterNdBatch2DSliceDim3ShapeRank7 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testString +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testUndefinedIndicesShape +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testUndefinedOutputShape +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testUndefinedUpdatesShape +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.test_session +scatter_nd_ops_test.ScatterNdTensorTest.testTensorScatterUpdateWithForwarding +scatter_nd_ops_test.ScatterNdTensorTest.testUpdateAddSub +scatter_nd_ops_test.ScatterNdTensorTest.testUpdateAddSubGradients +scatter_nd_ops_test.ScatterNdTensorTest.test_session +# This test fails on CPU backend on char (and maybe other data types) +# scatter_nd_ops_test.ScatterNdTest.testBool +scatter_nd_ops_test.ScatterNdTest.testEmptyOutputShape1 +# TODO: Test failing due to incorrect error message +# scatter_nd_ops_test.ScatterNdTest.testEmptyOutputShape2 +scatter_nd_ops_test.ScatterNdTest.testEmptyOutputShape3 +# This test fails on CPU backend on some unsupported data types +# scatter_nd_ops_test.ScatterNdTest.testExtraIndicesDimensions +scatter_nd_ops_test.ScatterNdTest.testGradientsRank2ElementUpdate +scatter_nd_ops_test.ScatterNdTest.testGradientsRank2SliceUpdate +scatter_nd_ops_test.ScatterNdTest.testGradientsRank3SliceUpdate +scatter_nd_ops_test.ScatterNdTest.testGradientsRank7SliceUpdate +scatter_nd_ops_test.ScatterNdTest.testInvalidShape +scatter_nd_ops_test.ScatterNdTest.testRank3InvalidShape1 +scatter_nd_ops_test.ScatterNdTest.testRank3InvalidShape2 +scatter_nd_ops_test.ScatterNdTest.testRank3ValidShape +scatter_nd_ops_test.ScatterNdTest.testScatterNdRepatedIndicesAdd +scatter_nd_ops_test.ScatterNdTest.testSmokeScatterNdBatch1DSliceDim2 +scatter_nd_ops_test.ScatterNdTest.testSmokeScatterNdBatch1DSliceDim3ShapeRank7 +scatter_nd_ops_test.ScatterNdTest.testSmokeScatterNdBatch2DSliceDim2 +scatter_nd_ops_test.ScatterNdTest.testSmokeScatterNdBatch2DSliceDim3ShapeRank7 +scatter_nd_ops_test.ScatterNdTest.testString +scatter_nd_ops_test.ScatterNdTest.testUndefinedIndicesShape +scatter_nd_ops_test.ScatterNdTest.testUndefinedOutputShape +scatter_nd_ops_test.ScatterNdTest.testUndefinedUpdatesShape +scatter_nd_ops_test.ScatterNdTest.test_session +scatter_nd_ops_test.StatefulScatterNdTest.testConcurrentUpdates +scatter_nd_ops_test.StatefulScatterNdTest.testExtraIndicesDimensions +scatter_nd_ops_test.StatefulScatterNdTest.testRank3InvalidShape1 +scatter_nd_ops_test.StatefulScatterNdTest.testRank3InvalidShape2 +scatter_nd_ops_test.StatefulScatterNdTest.testRank3ValidShape +scatter_nd_ops_test.StatefulScatterNdTest.testResVarInvalidOutputShape +scatter_nd_ops_test.StatefulScatterNdTest.testScatterOutOfRangeCpu +#scatter_nd_ops_test.StatefulScatterNdTest.testScatterRepeatIndices +scatter_nd_ops_test.StatefulScatterNdTest.testSimple +scatter_nd_ops_test.StatefulScatterNdTest.testSimple2 +scatter_nd_ops_test.StatefulScatterNdTest.testSimple3 +scatter_nd_ops_test.StatefulScatterNdTest.testSimpleResource +#scatter_nd_ops_test.StatefulScatterNdTest.testVariableRankAdd +#scatter_nd_ops_test.StatefulScatterNdTest.testVariableRankSub +#scatter_nd_ops_test.StatefulScatterNdTest.testVariableRankUpdate +scatter_nd_ops_test.StatefulScatterNdTest.test_session + slice_op_test.SliceTest.testComplex slice_op_test.SliceTest.testEmpty slice_op_test.SliceTest.testGradientsAll diff --git a/test/python/tensorflow/python_tests_list_gpu.txt b/test/python/tensorflow/python_tests_list_gpu.txt index f833ac398..5d4590a60 100644 --- a/test/python/tensorflow/python_tests_list_gpu.txt +++ b/test/python/tensorflow/python_tests_list_gpu.txt @@ -389,6 +389,73 @@ relu_op_test.ReluTest.testGradientFloat32 relu_op_test.ReluTest.testGradientScalar relu_op_test.ReluTest.testNumbers +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testBool +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testEmptyOutputShape1 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testEmptyOutputShape2 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testEmptyOutputShape3 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testExtraIndicesDimensions +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testGradientsRank2ElementUpdate +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testGradientsRank2SliceUpdate +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testGradientsRank3SliceUpdate +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testGradientsRank7SliceUpdate +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testInvalidShape +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testRank3InvalidShape1 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testRank3InvalidShape2 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testRank3ValidShape +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testScatterNdRepatedIndicesAdd +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testSmokeScatterNdBatch1DSliceDim2 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testSmokeScatterNdBatch1DSliceDim3ShapeRank7 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testSmokeScatterNdBatch2DSliceDim2 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testSmokeScatterNdBatch2DSliceDim3ShapeRank7 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testString +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testUndefinedIndicesShape +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testUndefinedOutputShape +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testUndefinedUpdatesShape +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.test_session +scatter_nd_ops_test.ScatterNdTensorTest.testTensorScatterUpdateWithForwarding +scatter_nd_ops_test.ScatterNdTensorTest.testUpdateAddSub +scatter_nd_ops_test.ScatterNdTensorTest.testUpdateAddSubGradients +scatter_nd_ops_test.ScatterNdTensorTest.test_session +scatter_nd_ops_test.ScatterNdTest.testBool +scatter_nd_ops_test.ScatterNdTest.testEmptyOutputShape1 +scatter_nd_ops_test.ScatterNdTest.testEmptyOutputShape2 +scatter_nd_ops_test.ScatterNdTest.testEmptyOutputShape3 +scatter_nd_ops_test.ScatterNdTest.testExtraIndicesDimensions +scatter_nd_ops_test.ScatterNdTest.testGradientsRank2ElementUpdate +scatter_nd_ops_test.ScatterNdTest.testGradientsRank2SliceUpdate +scatter_nd_ops_test.ScatterNdTest.testGradientsRank3SliceUpdate +scatter_nd_ops_test.ScatterNdTest.testGradientsRank7SliceUpdate +scatter_nd_ops_test.ScatterNdTest.testInvalidShape +scatter_nd_ops_test.ScatterNdTest.testRank3InvalidShape1 +scatter_nd_ops_test.ScatterNdTest.testRank3InvalidShape2 +scatter_nd_ops_test.ScatterNdTest.testRank3ValidShape +scatter_nd_ops_test.ScatterNdTest.testScatterNdRepatedIndicesAdd +scatter_nd_ops_test.ScatterNdTest.testSmokeScatterNdBatch1DSliceDim2 +scatter_nd_ops_test.ScatterNdTest.testSmokeScatterNdBatch1DSliceDim3ShapeRank7 +scatter_nd_ops_test.ScatterNdTest.testSmokeScatterNdBatch2DSliceDim2 +scatter_nd_ops_test.ScatterNdTest.testSmokeScatterNdBatch2DSliceDim3ShapeRank7 +scatter_nd_ops_test.ScatterNdTest.testString +scatter_nd_ops_test.ScatterNdTest.testUndefinedIndicesShape +scatter_nd_ops_test.ScatterNdTest.testUndefinedOutputShape +scatter_nd_ops_test.ScatterNdTest.testUndefinedUpdatesShape +scatter_nd_ops_test.ScatterNdTest.test_session +scatter_nd_ops_test.StatefulScatterNdTest.testConcurrentUpdates +scatter_nd_ops_test.StatefulScatterNdTest.testExtraIndicesDimensions +scatter_nd_ops_test.StatefulScatterNdTest.testRank3InvalidShape1 +scatter_nd_ops_test.StatefulScatterNdTest.testRank3InvalidShape2 +scatter_nd_ops_test.StatefulScatterNdTest.testRank3ValidShape +scatter_nd_ops_test.StatefulScatterNdTest.testResVarInvalidOutputShape +scatter_nd_ops_test.StatefulScatterNdTest.testScatterOutOfRangeCpu +#scatter_nd_ops_test.StatefulScatterNdTest.testScatterRepeatIndices +scatter_nd_ops_test.StatefulScatterNdTest.testSimple +scatter_nd_ops_test.StatefulScatterNdTest.testSimple2 +scatter_nd_ops_test.StatefulScatterNdTest.testSimple3 +scatter_nd_ops_test.StatefulScatterNdTest.testSimpleResource +#scatter_nd_ops_test.StatefulScatterNdTest.testVariableRankAdd +#scatter_nd_ops_test.StatefulScatterNdTest.testVariableRankSub +#scatter_nd_ops_test.StatefulScatterNdTest.testVariableRankUpdate +scatter_nd_ops_test.StatefulScatterNdTest.test_session + slice_op_test.SliceTest.testComplex slice_op_test.SliceTest.testEmpty slice_op_test.SliceTest.testGradientsAll diff --git a/test/python/tensorflow/python_tests_list_mac.txt b/test/python/tensorflow/python_tests_list_mac.txt index 5873d869a..7991da449 100644 --- a/test/python/tensorflow/python_tests_list_mac.txt +++ b/test/python/tensorflow/python_tests_list_mac.txt @@ -397,6 +397,74 @@ relu_op_test.ReluTest.testGradientFloat32 relu_op_test.ReluTest.testGradientFloat64 relu_op_test.ReluTest.testGradientScalar +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testBool +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testEmptyOutputShape1 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testEmptyOutputShape2 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testEmptyOutputShape3 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testExtraIndicesDimensions +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testGradientsRank2ElementUpdate +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testGradientsRank2SliceUpdate +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testGradientsRank3SliceUpdate +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testGradientsRank7SliceUpdate +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testInvalidShape +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testRank3InvalidShape1 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testRank3InvalidShape2 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testRank3ValidShape +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testScatterNdRepatedIndicesAdd +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testSmokeScatterNdBatch1DSliceDim2 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testSmokeScatterNdBatch1DSliceDim3ShapeRank7 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testSmokeScatterNdBatch2DSliceDim2 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testSmokeScatterNdBatch2DSliceDim3ShapeRank7 +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testString +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testUndefinedIndicesShape +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testUndefinedOutputShape +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.testUndefinedUpdatesShape +scatter_nd_ops_test.ScatterNdNonAliasingAddTest.test_session +scatter_nd_ops_test.ScatterNdTensorTest.testTensorScatterUpdateWithForwarding +scatter_nd_ops_test.ScatterNdTensorTest.testUpdateAddSub +scatter_nd_ops_test.ScatterNdTensorTest.testUpdateAddSubGradients +scatter_nd_ops_test.ScatterNdTensorTest.test_session +# scatter_nd_ops_test.ScatterNdTest.testBool +scatter_nd_ops_test.ScatterNdTest.testEmptyOutputShape1 +# scatter_nd_ops_test.ScatterNdTest.testEmptyOutputShape2 +scatter_nd_ops_test.ScatterNdTest.testEmptyOutputShape3 +# scatter_nd_ops_test.ScatterNdTest.testExtraIndicesDimensions +scatter_nd_ops_test.ScatterNdTest.testGradientsRank2ElementUpdate +scatter_nd_ops_test.ScatterNdTest.testGradientsRank2SliceUpdate +scatter_nd_ops_test.ScatterNdTest.testGradientsRank3SliceUpdate +scatter_nd_ops_test.ScatterNdTest.testGradientsRank7SliceUpdate +scatter_nd_ops_test.ScatterNdTest.testInvalidShape +scatter_nd_ops_test.ScatterNdTest.testRank3InvalidShape1 +scatter_nd_ops_test.ScatterNdTest.testRank3InvalidShape2 +scatter_nd_ops_test.ScatterNdTest.testRank3ValidShape +scatter_nd_ops_test.ScatterNdTest.testScatterNdRepatedIndicesAdd +scatter_nd_ops_test.ScatterNdTest.testSmokeScatterNdBatch1DSliceDim2 +scatter_nd_ops_test.ScatterNdTest.testSmokeScatterNdBatch1DSliceDim3ShapeRank7 +scatter_nd_ops_test.ScatterNdTest.testSmokeScatterNdBatch2DSliceDim2 +scatter_nd_ops_test.ScatterNdTest.testSmokeScatterNdBatch2DSliceDim3ShapeRank7 +scatter_nd_ops_test.ScatterNdTest.testString +scatter_nd_ops_test.ScatterNdTest.testUndefinedIndicesShape +scatter_nd_ops_test.ScatterNdTest.testUndefinedOutputShape +scatter_nd_ops_test.ScatterNdTest.testUndefinedUpdatesShape +scatter_nd_ops_test.ScatterNdTest.test_session +scatter_nd_ops_test.StatefulScatterNdTest.testConcurrentUpdates +scatter_nd_ops_test.StatefulScatterNdTest.testExtraIndicesDimensions +scatter_nd_ops_test.StatefulScatterNdTest.testRank3InvalidShape1 +scatter_nd_ops_test.StatefulScatterNdTest.testRank3InvalidShape2 +scatter_nd_ops_test.StatefulScatterNdTest.testRank3ValidShape +scatter_nd_ops_test.StatefulScatterNdTest.testResVarInvalidOutputShape +scatter_nd_ops_test.StatefulScatterNdTest.testScatterOutOfRangeCpu +#scatter_nd_ops_test.StatefulScatterNdTest.testScatterRepeatIndices +scatter_nd_ops_test.StatefulScatterNdTest.testSimple +scatter_nd_ops_test.StatefulScatterNdTest.testSimple2 +scatter_nd_ops_test.StatefulScatterNdTest.testSimple3 +scatter_nd_ops_test.StatefulScatterNdTest.testSimpleResource +#scatter_nd_ops_test.StatefulScatterNdTest.testVariableRankAdd +#scatter_nd_ops_test.StatefulScatterNdTest.testVariableRankSub +#scatter_nd_ops_test.StatefulScatterNdTest.testVariableRankUpdate +scatter_nd_ops_test.StatefulScatterNdTest.test_session + + slice_op_test.SliceTest.testComplex slice_op_test.SliceTest.testEmpty slice_op_test.SliceTest.testGradientsAll diff --git a/test/test_array_ops.cpp b/test/test_array_ops.cpp index a6d29a362..7bbdbbaa8 100644 --- a/test/test_array_ops.cpp +++ b/test/test_array_ops.cpp @@ -902,6 +902,94 @@ TEST(ArrayOps, Rank) { opexecuter.RunTest(); } // end of RankOp +// Test op: ScatterNd Op +TEST(ArrayOps, ScatterNd1D) { + Tensor indices(DT_INT32, TensorShape({4, 1})); + Tensor updates(DT_FLOAT, TensorShape({4})); + + AssignInputValues(indices, {{2}, {3}, {1}, {7}}); + AssignInputValues(updates, {9.1, 10.2, -11.3, 12.4}); + + vector static_input_indexes = {2}; + + vector output_datatypes = {DT_FLOAT}; + + Scope root = Scope::NewRootScope(); + auto R = ops::ScatterNd(root, indices, updates, {8}); + std::vector sess_run_fetchoutputs = {R}; + + OpExecuter opexecuter(root, "ScatterNd", static_input_indexes, + output_datatypes, sess_run_fetchoutputs); + + opexecuter.RunTest(); +} + +TEST(ArrayOps, ScatterNdRepeatIndices) { + Tensor indices(DT_INT32, TensorShape({4, 1})); + Tensor updates(DT_FLOAT, TensorShape({4})); + + // the index "2" appears twice + AssignInputValues(indices, {{2}, {3}, {2}, {7}}); + AssignInputValues(updates, {9.1, 10.2, -11.3, 12.4}); + + vector static_input_indexes = {2}; + + vector output_datatypes = {DT_FLOAT}; + + Scope root = Scope::NewRootScope(); + auto R = ops::ScatterNd(root, indices, updates, {10}); + std::vector sess_run_fetchoutputs = {R}; + + OpExecuter opexecuter(root, "ScatterNd", static_input_indexes, + output_datatypes, sess_run_fetchoutputs); + + opexecuter.RunTest(); +} + +TEST(ArrayOps, ScatterNdComplex) { + // indices.shape[-1] <= shape.rank + // updates.shape = indices.shape[:-1] + shape[indices.shape[-1]:] + // shape must be rank 1 + Tensor indices(DT_INT32, TensorShape({2, 2, 2})); + Tensor updates(DT_FLOAT, TensorShape({2, 2, 2})); + + AssignInputValuesRandom(indices, 0, 1); + AssignInputValuesRandom(updates, -10.0, 20.0f); + + vector static_input_indexes = {2}; + + vector output_datatypes = {DT_FLOAT}; + + Scope root = Scope::NewRootScope(); + auto R = ops::ScatterNd(root, indices, updates, {2, 2, 2}); + std::vector sess_run_fetchoutputs = {R}; + + OpExecuter opexecuter(root, "ScatterNd", static_input_indexes, + output_datatypes, sess_run_fetchoutputs); + opexecuter.RunTest(); +} + +TEST(ArrayOps, ScatterNd3D) { + Tensor indices(DT_INT32, TensorShape({2, 1})); + Tensor updates(DT_FLOAT, TensorShape({2, 4, 4})); + + AssignInputValues(indices, {{0}, {2}}); + AssignInputValuesRandom(updates, -10.0, 20.0f); + + vector static_input_indexes = {2}; + + vector output_datatypes = {DT_FLOAT}; + + Scope root = Scope::NewRootScope(); + auto R = ops::ScatterNd(root, indices, updates, {4, 4, 4}); + std::vector sess_run_fetchoutputs = {R}; + + OpExecuter opexecuter(root, "ScatterNd", static_input_indexes, + output_datatypes, sess_run_fetchoutputs); + + opexecuter.RunTest(); +} // end of test op ScatterNd + // Test op: Shape, outputs the shape of a tensor TEST(ArrayOps, Shape2D) { Scope root = Scope::NewRootScope();