From ba8226fcb432c3e356700969d8c9ee10bcd67865 Mon Sep 17 00:00:00 2001 From: Vladimir Paramuzov Date: Thu, 18 Jun 2020 19:55:17 +0300 Subject: [PATCH] [IE CLDNN] Fix strided slice (#950) --- .../src/cldnn_engine/cldnn_program.cpp | 4 +- .../single_layer_tests/strided_slice.cpp | 65 +++++++++++-- .../src/single_layer_tests/strided_slice.cpp | 8 +- .../tests/ngraph_functions/src/strided_slice.cpp | 5 +- .../thirdparty/clDNN/api/strided_slice.hpp | 17 ++-- .../strided_slice/strided_slice_kernel_ref.cpp | 108 ++++++++++++++++++--- .../strided_slice/strided_slice_kernel_ref.h | 5 +- .../core/cl_kernels/strided_slice_ref.cl | 18 +++- .../thirdparty/clDNN/src/gpu/strided_slice_gpu.cpp | 31 ++++-- .../thirdparty/clDNN/src/strided_slice.cpp | 78 +-------------- .../tests/test_cases/removing_output_node_test.cpp | 4 +- .../tests/test_cases/strided_slice_gpu_test.cpp | 50 +++++----- 12 files changed, 242 insertions(+), 151 deletions(-) diff --git a/inference-engine/src/cldnn_engine/cldnn_program.cpp b/inference-engine/src/cldnn_engine/cldnn_program.cpp index 4ad4cf8..3b6b37a 100644 --- a/inference-engine/src/cldnn_engine/cldnn_program.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_program.cpp @@ -3944,11 +3944,13 @@ void Program::CreateStridedSlicePrimitive(cldnn::topology& topology, InferenceEn tmp = stridedSliceLayer->GetParamAsUInts("shrink_axis_mask"); std::vector shrink_axis_mask(tmp.begin(), tmp.end()); + auto out_size = CldnnTensorFromIEDims(stridedSliceLayer->outData[0]->getTensorDesc().getDims()); + std::string stridedSliceLayerName = layer_type_name_ID(layer); auto stridedSlicePrim = cldnn::strided_slice( stridedSliceLayerName, inputPrimitives[0], inputPrimitives[1], inputPrimitives[2], inputPrimitives[3], - begin_mask, end_mask, new_axis_mask, shrink_axis_mask); + begin_mask, end_mask, new_axis_mask, shrink_axis_mask, out_size); topology.add(stridedSlicePrim); AddPrimitiveToProfiler(stridedSliceLayerName, layer); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/strided_slice.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/strided_slice.cpp index 6d6c5b9..236a7e6 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/strided_slice.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/strided_slice.cpp @@ -12,35 +12,80 @@ using namespace LayerTestsDefinitions; namespace { stridedSliceParamsTuple ss_only_test_cases[] = { + stridedSliceParamsTuple({ 128, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 1, 1, 1 }, + { 0, 1, 1 }, { 0, 1, 1 }, { 1, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, + InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), + stridedSliceParamsTuple({ 128, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 1, 1, 1}, + { 1, 0, 1 }, { 1, 0, 1 }, { 0, 1, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, + InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), + stridedSliceParamsTuple({ 1, 12, 100 }, { 0, -1, 0 }, { 0, 0, 0 }, { 1, 1, 1 }, + { 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 1, 0 }, { 0, 0, 0 }, + InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), + stridedSliceParamsTuple({ 1, 12, 100 }, { 0, 9, 0 }, { 0, 11, 0 }, { 1, 1, 1 }, + { 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, + InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), + stridedSliceParamsTuple({ 1, 12, 100 }, { 0, 1, 0 }, { 0, -1, 0 }, { 1, 1, 1 }, + { 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, + InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), + stridedSliceParamsTuple({ 1, 12, 100 }, { 0, 9, 0 }, { 0, 8, 0 }, { 1, -1, 1 }, + { 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, + InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), + stridedSliceParamsTuple({ 1, 12, 100 }, { 0, 9, 0 }, { 0, 7, 0 }, { -1, -1, -1 }, + { 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, + InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), + stridedSliceParamsTuple({ 1, 12, 100 }, { 0, 7, 0 }, { 0, 9, 0 }, { -1, 1, -1 }, + { 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, + InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), + stridedSliceParamsTuple({ 1, 12, 100 }, { 0, 4, 0 }, { 0, 9, 0 }, { -1, 2, -1 }, + { 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, + InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), + stridedSliceParamsTuple({ 1, 12, 100 }, { 0, 4, 0 }, { 0, 10, 0 }, { -1, 2, -1 }, + { 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, + InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), + stridedSliceParamsTuple({ 1, 12, 100 }, { 0, 9, 0 }, { 0, 4, 0 }, { -1, -2, -1 }, + { 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, + InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), + stridedSliceParamsTuple({ 1, 12, 100 }, { 0, 10, 0 }, { 0, 4, 0 }, { -1, -2, -1 }, + { 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, + InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), + stridedSliceParamsTuple({ 1, 12, 100 }, { 0, 11, 0 }, { 0, 0, 0 }, { -1, -2, -1 }, + { 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, + InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), + stridedSliceParamsTuple({ 1, 12, 100 }, { 0, -6, 0 }, { 0, -8, 0 }, { -1, -2, -1 }, + { 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, + InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), + stridedSliceParamsTuple({ 1, 12, 100, 1, 1 }, { 0, -1, 0, 0 }, { 0, 0, 0, 0 }, { 1, 1, 1, 1 }, + { 1, 0, 1, 0 }, { 1, 0, 1, 0 }, { }, { 0, 1, 0, 1 }, {}, + InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), stridedSliceParamsTuple({ 2, 2, 2, 2 }, { 0, 0, 0, 0 }, { 2, 2, 2, 2 }, { 1, 1, 1, 1 }, - {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, + {1, 1, 1, 1}, {1, 1, 1, 1}, {}, {}, {}, InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), stridedSliceParamsTuple({ 2, 2, 2, 2 }, { 1, 1, 1, 1 }, { 2, 2, 2, 2 }, { 1, 1, 1, 1 }, - {0, 0, 0, 0}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, + {0, 0, 0, 0}, {1, 1, 1, 1}, {}, {}, {}, InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), stridedSliceParamsTuple({ 2, 2, 2, 2 }, { 1, 1, 1, 1 }, { 2, 2, 2, 2 }, { 1, 1, 1, 1 }, - {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, + {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {}, InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), stridedSliceParamsTuple({ 2, 2, 4, 3 }, { 0, 0, 0, 0 }, { 2, 2, 4, 3 }, { 1, 1, 2, 1 }, - {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, + {1, 1, 1, 1}, {1, 1, 1, 1}, {}, {}, {}, InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), stridedSliceParamsTuple({ 2, 2, 4, 2 }, { 1, 0, 0, 1 }, { 2, 2, 4, 2 }, { 1, 1, 2, 1 }, - {0, 1, 1, 0}, {1, 1, 0, 0}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, + {0, 1, 1, 0}, {1, 1, 0, 0}, {}, {}, {}, InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), stridedSliceParamsTuple({ 1, 2, 4, 2 }, { 1, 0, 0, 0 }, { 1, 2, 4, 2 }, { 1, 1, -2, -1 }, - {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, + {1, 1, 1, 1}, {1, 1, 1, 1}, {}, {}, {}, InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), stridedSliceParamsTuple({ 2, 2, 4, 2 }, { 1, 0, 0, 0 }, { 1, 2, 4, 2 }, { 1, 1, -2, -1 }, - {0, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, + {0, 1, 1, 1}, {1, 1, 1, 1}, {}, {}, {}, InferenceEngine::Precision::FP32, CommonTestUtils::DEVICE_GPU), stridedSliceParamsTuple({ 2, 2, 2, 2 }, { 0, 0, 0, 0 }, { 2, 2, 2, 2 }, { 1, 1, 1, 1 }, - {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, + {1, 1, 1, 1}, {1, 1, 1, 1}, {}, {}, {}, InferenceEngine::Precision::I64, CommonTestUtils::DEVICE_GPU), stridedSliceParamsTuple({ 2, 2, 2, 2 }, { 1, 1, 1, 1 }, { 2, 2, 2, 2 }, { 1, 1, 1, 1 }, - {0, 0, 0, 0}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, + {0, 0, 0, 0}, {1, 1, 1, 1}, {}, {}, {}, InferenceEngine::Precision::I64, CommonTestUtils::DEVICE_GPU), stridedSliceParamsTuple({ 2, 2, 2, 2 }, { 1, 1, 1, 1 }, { 2, 2, 2, 2 }, { 1, 1, 1, 1 }, - {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, + {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {}, InferenceEngine::Precision::I64, CommonTestUtils::DEVICE_GPU), }; diff --git a/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/strided_slice.cpp b/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/strided_slice.cpp index e237081..165ebc4 100644 --- a/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/strided_slice.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/strided_slice.cpp @@ -36,10 +36,10 @@ std::string StridedSliceLayerTest::getTestCaseName(const testing::TestParamInfo< result << "stride=" << CommonTestUtils::vec2str(stride) << "_"; result << "begin_m=" << CommonTestUtils::vec2str(begin_mask) << "_"; result << "end_m=" << CommonTestUtils::vec2str(end_mask) << "_"; - result << "new_axis_m=" << CommonTestUtils::vec2str(new_axis_mask) << "_"; - result << "shrink_m=" << CommonTestUtils::vec2str(shrink_mask) << "_"; - result << "ellipsis_m=" << CommonTestUtils::vec2str(ellipsis_mask) << "_"; - result << "targetDevice=" << targetName << "_"; + result << "new_axis_m=" << (new_axis_mask.empty() ? "def" : CommonTestUtils::vec2str(new_axis_mask)) << "_"; + result << "shrink_m=" << (shrink_mask.empty() ? "def" : CommonTestUtils::vec2str(shrink_mask)) << "_"; + result << "ellipsis_m=" << (ellipsis_mask.empty() ? "def" : CommonTestUtils::vec2str(ellipsis_mask)) << "_"; + result << "targetDevice=" << targetName; return result.str(); } diff --git a/inference-engine/tests/ngraph_functions/src/strided_slice.cpp b/inference-engine/tests/ngraph_functions/src/strided_slice.cpp index 5fdd48b..188956a 100644 --- a/inference-engine/tests/ngraph_functions/src/strided_slice.cpp +++ b/inference-engine/tests/ngraph_functions/src/strided_slice.cpp @@ -16,11 +16,12 @@ std::shared_ptr makeStridedSlice(const ngraph::Output &in, const std::vector &new_axis_mask, const std::vector &shrink_mask, const std::vector &ellipsis_mask) { - ngraph::Shape constShape = {in.get_shape().size()}; + ngraph::Shape constShape = {begin.size()}; auto beginNode = std::make_shared(ngraph::element::i64, constShape, begin.data()); auto endNode = std::make_shared(ngraph::element::i64, constShape, end.data()); auto strideNode = std::make_shared(ngraph::element::i64, constShape, stride.data()); - auto ssNode = std::make_shared(in, beginNode, endNode, strideNode, begin_mask, end_mask); + auto ssNode = std::make_shared(in, beginNode, endNode, strideNode, begin_mask, end_mask, + new_axis_mask, shrink_mask, ellipsis_mask); return ssNode; } diff --git a/inference-engine/thirdparty/clDNN/api/strided_slice.hpp b/inference-engine/thirdparty/clDNN/api/strided_slice.hpp index d3fdfa3..ddc7d37 100644 --- a/inference-engine/thirdparty/clDNN/api/strided_slice.hpp +++ b/inference-engine/thirdparty/clDNN/api/strided_slice.hpp @@ -1,5 +1,5 @@ /* -// Copyright (c) 2019 Intel Corporation +// Copyright (c) 2019-2020 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -42,6 +42,7 @@ struct strided_slice : public primitive_base { /// @param end_mask Array of bits, that provide replace end[i] to max possible range in that dimension. /// @param new_axis_mask Array of bits, that provide adding a new length 1 dimension at ith position in the output tensor. /// @param shrink_axis_mask Array of bits, that provide shrinks the dimensionality by 1, taking on the value at index begin[i]. + /// @param out_size Size of output tensor strided_slice(const primitive_id& id, const primitive_id& input, const primitive_id& begin_id, @@ -51,21 +52,25 @@ struct strided_slice : public primitive_base { std::vector end_mask, std::vector new_axis_mask, std::vector shrink_axis_mask, + const tensor out_size, const padding& output_padding = padding()) : primitive_base(id, {input, begin_id, end_id, strides_id}, output_padding), begin_mask(begin_mask), end_mask(end_mask), new_axis_mask(new_axis_mask), - shrink_axis_mask(shrink_axis_mask) {} + shrink_axis_mask(shrink_axis_mask), + out_size(out_size) {} - /// @param begin_mask Array of bits, that provide replace begin[i] to max possible range in that dimension. + /// @brief Array of bits, that provide replace begin[i] to max possible range in that dimension. std::vector begin_mask; - /// @param end_mask Array of bits, that provide replace end[i] to max possible range in that dimension. + /// @brief Array of bits, that provide replace end[i] to max possible range in that dimension. std::vector end_mask; - /// @param new_axis_mask Array of bits, that provide adding a new length 1 dimension at ith position in the output tensor. + /// @brief Array of bits, that provide adding a new length 1 dimension at ith position in the output tensor. std::vector new_axis_mask; - /// @param shrink_axis_mask Array of bits, that provide shrinks the dimensionality by 1, taking on the value at index begin[i]. + /// @brief Array of bits, that provide shrinks the dimensionality by 1, taking on the value at index begin[i]. std::vector shrink_axis_mask; + /// @brief Size of output tensor + tensor out_size; }; /// @} /// @} diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/strided_slice/strided_slice_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/strided_slice/strided_slice_kernel_ref.cpp index dd7104a..78c1518 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/strided_slice/strided_slice_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/strided_slice/strided_slice_kernel_ref.cpp @@ -18,6 +18,35 @@ #include namespace kernel_selector { + +template +static void makeJitConstForParam(JitConstants& jit, const std::string name, const T& vec) { + jit.AddConstant(MakeJitConstant(name + "_SIZES", vec)); + jit.AddConstant(MakeJitConstant(name + "_BATCH", vec[0])); + jit.AddConstant(MakeJitConstant(name + "_FEATURE", vec[1])); + if (vec.size() == 5) { // BFZYX + jit.AddConstant(MakeJitConstant(name + "_Z", vec[2])); + jit.AddConstant(MakeJitConstant(name + "_Y", vec[3])); + jit.AddConstant(MakeJitConstant(name + "_X", vec[4])); + } else { // BFYX + jit.AddConstant(MakeJitConstant(name + "_Z", 0)); + jit.AddConstant(MakeJitConstant(name + "_Y", vec[2])); + jit.AddConstant(MakeJitConstant(name + "_X", vec[3])); + } +}; + +static size_t GetUsedOutDimsCount(const strided_slice_params& params) { + auto dims = params.output.GetDims(); + size_t first_non_unit_dim = 0; // order is xy(z)fb, so by default consider that we use all dims + for (size_t i = 0; i < dims.size(); i++) { + if (dims[i].v != 1) { + break; + } + first_non_unit_dim = i; + } + return dims.size() - first_non_unit_dim; +} + ParamsKey StridedSliceKernelRef::GetSupportedKey() const { ParamsKey k; k.EnableInputDataType(Datatype::F16); @@ -32,6 +61,33 @@ ParamsKey StridedSliceKernelRef::GetSupportedKey() const { return k; } +bool StridedSliceKernelRef::Validate(const Params& p, const optional_params& o) const { + if (p.GetType() != KernelType::STRIDED_SLICE || o.GetType() != KernelType::STRIDED_SLICE) { + return false; + } + + const strided_slice_params& params = static_cast(p); + if (params.inputs.empty()) + return false; + + if (params.output.Dimentions() > 5 || params.inputs[0].Dimentions() > 5) + return false; + + bool shrink_mode = std::find(params.shrink_axis_mask.begin(), params.shrink_axis_mask.end(), 1) != params.shrink_axis_mask.end(); + if (shrink_mode) { + size_t shrinked_axes = std::count_if(params.shrink_axis_mask.begin(), params.shrink_axis_mask.end(), [](const uint8_t& v) { + return v == 1; + }); + size_t used_out_dims = GetUsedOutDimsCount(params); + + // Count of actual output dims + count of shrinked axes shouldn't exceed 5 to be able to find input index correctly + if (used_out_dims + shrinked_axes > 5) { + return false; + } + } + return true; +} + CommonDispatchData StridedSliceKernelRef::SetDefault(const strided_slice_params& params, const optional_params&) const { CommonDispatchData runInfo; @@ -57,21 +113,6 @@ CommonDispatchData StridedSliceKernelRef::SetDefault(const strided_slice_params& JitConstants StridedSliceKernelRef::GetJitConstants(const strided_slice_params& params) const { JitConstants jit = MakeBaseParamsJitConstants(params); - auto makeJitConstForParam = [](JitConstants& jit, const std::string name, const std::vector vec) { - jit.AddConstant(MakeJitConstant(name + "_SIZES", vec)); - jit.AddConstant(MakeJitConstant(name + "_BATCH", vec[0])); - jit.AddConstant(MakeJitConstant(name + "_FEATURE", vec[1])); - if (vec.size() == 5) { // BFZYX - jit.AddConstant(MakeJitConstant(name + "_Z", vec[2])); - jit.AddConstant(MakeJitConstant(name + "_Y", vec[3])); - jit.AddConstant(MakeJitConstant(name + "_X", vec[4])); - } else { // BFYX - jit.AddConstant(MakeJitConstant(name + "_Z", 0)); - jit.AddConstant(MakeJitConstant(name + "_Y", vec[2])); - jit.AddConstant(MakeJitConstant(name + "_X", vec[3])); - } - }; - makeJitConstForParam(jit, "SLICE_BEGIN", params.striding_params[0]); makeJitConstForParam(jit, "SLICE_END", params.striding_params[1]); makeJitConstForParam(jit, "SLICE_STEPS", params.striding_params[2]); @@ -80,10 +121,47 @@ JitConstants StridedSliceKernelRef::GetJitConstants(const strided_slice_params& "NEW_AXIS_MODE", std::find(params.new_axis_mask.begin(), params.new_axis_mask.end(), 1) != params.new_axis_mask.end())); + bool shrink_mode = std::find(params.shrink_axis_mask.begin(), params.shrink_axis_mask.end(), 1) != params.shrink_axis_mask.end(); + if (shrink_mode) { + jit.AddConstant(MakeJitConstant("SHRINK_MODE", true)); + makeJitConstForParam(jit, "SHRINK", params.shrink_axis_mask); + std::vector bfzyx_in_order; + if (params.output.Dimentions() == 5) + bfzyx_in_order = {"batch", "feature", "z", "y", "x"}; + else + bfzyx_in_order = {"batch", "feature", "y", "x"}; + + // Insert zeroes to indices order for shinked axes + for (size_t i = 0; i < params.shrink_axis_mask.size(); i++) { + if (params.shrink_axis_mask[i] == 1) { + bfzyx_in_order.insert(bfzyx_in_order.begin() + i, "0"); + } + } + + auto get_input_idx_order = [&](std::vector bfzyx_in_order) -> std::string { + return bfzyx_in_order[0] + "," + + bfzyx_in_order[1] + "," + + bfzyx_in_order[2] + "," + + bfzyx_in_order[3] + "," + + bfzyx_in_order[4]; + }; + // Erase indices that exceeds 5d tensor. It should be safe, because we check in Validate method that + // shrinked axes don't result in too big dims count + while (bfzyx_in_order.size() > 5) { + bfzyx_in_order.pop_back(); + } + + jit.AddConstant(MakeJitConstant("INPUT_INDICES_ORDER", get_input_idx_order(bfzyx_in_order))); + } + return jit; } KernelsData StridedSliceKernelRef::GetKernelsData(const Params& params, const optional_params& options) const { + if (!Validate(params, options)) { + return {}; + } + KernelData kd = KernelData::Default(params); strided_slice_params& newParams = *static_cast(kd.params.get()); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/strided_slice/strided_slice_kernel_ref.h b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/strided_slice/strided_slice_kernel_ref.h index f71b802..c37d299 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/strided_slice/strided_slice_kernel_ref.h +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/strided_slice/strided_slice_kernel_ref.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019 Intel Corporation +// Copyright (c) 2019-2020 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -49,5 +49,8 @@ public: virtual CommonDispatchData SetDefault(const strided_slice_params& params, const optional_params&) const; KernelsData GetKernelsData(const Params& params, const optional_params& options) const override; ParamsKey GetSupportedKey() const override; + +protected: + bool Validate(const Params& p, const optional_params& o) const override; }; } // namespace kernel_selector diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/cl_kernels/strided_slice_ref.cl b/inference-engine/thirdparty/clDNN/kernel_selector/core/cl_kernels/strided_slice_ref.cl index ed98138..085837e 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/cl_kernels/strided_slice_ref.cl +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/cl_kernels/strided_slice_ref.cl @@ -1,4 +1,4 @@ -// Copyright (c) 2019 Intel Corporation +// Copyright (c) 2019-2020 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -50,12 +50,28 @@ KERNEL(strided_slice_ref)(const __global UNIT_TYPE* input, __global UNIT_TYPE* o const uint y = yx / OUTPUT_SIZE_X; const uint x = yx % OUTPUT_SIZE_X; #endif + +#if SHRINK_MODE + const uint in_indices[] = {INPUT_INDICES_ORDER}; + const uint input_index = INPUT0_OFFSET + + (SLICE_BEGIN_BATCH + in_indices[0] * SLICE_STEPS_BATCH) * INPUT0_BATCH_PITCH + + (SLICE_BEGIN_FEATURE + in_indices[1] * SLICE_STEPS_FEATURE) * INPUT0_FEATURE_PITCH + + #if INPUT0_LAYOUT_BFZYX + (SLICE_BEGIN_Z + in_indices[2] * SLICE_STEPS_Z) * INPUT0_Z_PITCH + + (SLICE_BEGIN_Y + in_indices[3] * SLICE_STEPS_Y) * INPUT0_Y_PITCH + + (SLICE_BEGIN_X + in_indices[4] * SLICE_STEPS_X) * INPUT0_X_PITCH; + #else + (SLICE_BEGIN_Y + in_indices[2] * SLICE_STEPS_Y) * INPUT0_Y_PITCH + + (SLICE_BEGIN_X + in_indices[3] * SLICE_STEPS_X) * INPUT0_X_PITCH; + #endif +#else // SHRINK_MODE const uint input_index = INPUT0_OFFSET + (SLICE_BEGIN_BATCH + batch * SLICE_STEPS_BATCH) * INPUT0_BATCH_PITCH + (SLICE_BEGIN_FEATURE + feature * SLICE_STEPS_FEATURE) * INPUT0_FEATURE_PITCH + (SLICE_BEGIN_Z + z * SLICE_STEPS_Z) * INPUT0_Z_PITCH + (SLICE_BEGIN_Y + y * SLICE_STEPS_Y) * INPUT0_Y_PITCH + (SLICE_BEGIN_X + x * SLICE_STEPS_X) * INPUT0_X_PITCH; +#endif // SHRINK_MODE const uint output_index = OUTPUT_OFFSET + batch * OUTPUT_BATCH_PITCH + diff --git a/inference-engine/thirdparty/clDNN/src/gpu/strided_slice_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/strided_slice_gpu.cpp index 9914fda..2c9b060 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/strided_slice_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/strided_slice_gpu.cpp @@ -1,5 +1,5 @@ /* -// Copyright (c) 2019 Intel Corporation +// Copyright (c) 2019-2020 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -77,14 +77,29 @@ public: // If the ith bit of end_mask is not set, end[i] is ignored and the fullest possible range in that dimension is used // instead. vector_assign_if_not_mask(params.striding_params[1], out_shape, params.end_mask); - for (size_t dim = 0; dim < params.striding_params[2].size(); dim++) { - auto begin = params.striding_params[0][dim] < 0 ? out_shape[dim] + params.striding_params[0][dim] : params.striding_params[0][dim]; - auto end = params.striding_params[1][dim] < 0 ? out_shape[dim] + params.striding_params[1][dim] : params.striding_params[1][dim]; - auto stride = params.striding_params[2][dim]; - if (stride < 0 && (end > begin)) { - std::swap(params.striding_params[0][dim], params.striding_params[1][dim]); - params.striding_params[0][dim] = params.striding_params[0][dim] - 1; + if (params.striding_params[0][dim] < 0) + params.striding_params[0][dim] = std::max(out_shape[dim] + params.striding_params[0][dim], (int32_t)0); + if (params.striding_params[1][dim] < 0) + params.striding_params[1][dim] = std::max(out_shape[dim] + params.striding_params[1][dim], (int32_t)0); + + params.striding_params[0][dim] = std::min(params.striding_params[0][dim], out_shape[dim]); + params.striding_params[1][dim] = std::min(params.striding_params[1][dim], out_shape[dim]); + + auto& begin = params.striding_params[0][dim]; + auto& end = params.striding_params[1][dim]; + auto& stride = params.striding_params[2][dim]; + bool is_reverse = stride < 0; + // If begin > end && is_reverse, then we don't need to adjust begin/end values, the kernel will process it correctly + // If begin <= end, then we swap begin/end values and subtruct 1 from each of them + // E.g. out_shape[dim] = 100; begin=0; end=100; stride=-1 + // swap: begin=100; end=0; + // sub: begin=99; end=-1; + // So the kernel will put the slices [99, 0] in reversed order as expected. + if (is_reverse && begin <= end) { + std::swap(begin, end); + begin--; + end--; } } diff --git a/inference-engine/thirdparty/clDNN/src/strided_slice.cpp b/inference-engine/thirdparty/clDNN/src/strided_slice.cpp index d6cc1de..f792187 100644 --- a/inference-engine/thirdparty/clDNN/src/strided_slice.cpp +++ b/inference-engine/thirdparty/clDNN/src/strided_slice.cpp @@ -1,5 +1,5 @@ /* -// Copyright (c) 2019 Intel Corporation +// Copyright (c) 2019-2020 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -32,81 +32,7 @@ layout strided_slice_inst::calc_output_layout(strided_slice_node const& node) { auto desc = node.get_primitive(); auto input_layout = node.input(0).get_output_layout(); auto input_format = input_layout.format; - const size_t dims_num = format::dimension(input_format); - format dimension_format = get_default_format_for_dim(dims_num); - - // Getting data from constant inputs. There are 3 args: Begin, End, Stride - std::vector> args; - for (size_t i = 1; i < node.get_dependencies().size(); ++i) { - auto& input = node.get_dependency(i).as(); - auto& mem = input.get_attached_memory(); - std::vector sizes; - if (input.get_output_layout().data_type == cldnn::data_types::i64) { - int64_t* data = static_cast(mem.lock()); - std::vector sizes_i64 = std::vector(data, data + input.get_output_layout().count()); - sizes.resize(sizes_i64.size()); - for (size_t j = 0; j < sizes.size(); j++) - sizes[j] = static_cast(sizes_i64[j]); - } else { - int32_t* data = static_cast(mem.lock()); - sizes = std::vector(data, data + input.get_output_layout().count()); - } - pad_vector_to_size(sizes, dims_num, i != 1); // for "begin" completion used 0 value, for other - 1 - args.push_back(sizes); - mem.unlock(); - } - - std::vector begin_mask(desc->begin_mask); - pad_vector_to_size(begin_mask, dims_num, 1); - std::vector end_mask(desc->end_mask); - pad_vector_to_size(end_mask, dims_num, 1); - - auto& begin = args[0]; - auto& end = args[1]; - const auto& strides = args[2]; - - for (size_t i = 0; i < dims_num; ++i) { - auto max_size = input_layout.size.sizes(dimension_format)[i]; - if (end[i] > max_size) { - end[i] = max_size; - } else if (end[i] < 0) { - end[i] = end[i] % max_size; - } - if (begin[i] < 0) { - begin[i] = begin[i] % max_size; - } - } - - // If the ith bit of begin_mask is not set, begin[i] is ignored and the range of the appropriate dimension starts from 0. - vector_assign_if_not_mask(begin, 0, begin_mask); - // If the ith bit of end_mask is not set, end[i] is ignored and the fullest possible range in that dimension is used - // instead. - vector_assign_if_not_mask(end, input_layout.size.sizes(dimension_format), end_mask); - - std::vector output_shape; - if (std::find(desc->new_axis_mask.begin(), desc->new_axis_mask.end(), 1) == desc->new_axis_mask.end()) { - for (size_t i = 0; i < dims_num; ++i) { - int32_t b = begin[i] < 0 ? input_layout.size.sizes(input_format)[i] - 1 : begin[i]; - int32_t e = end[i] < 0 ? input_layout.size.sizes(input_format)[i] - 1 : end[i]; - int32_t s = strides[i]; - int32_t outputDimSize = std::abs((e - b) / s); - if ((e - b) % s != 0) - outputDimSize++; - output_shape.push_back(outputDimSize); - } - } else { - output_shape = input_layout.size.sizes(input_format); - } - - if (input_format == format::bfzyx) - return layout{input_layout.data_type, - input_format, - tensor(batch(output_shape[0]), feature(output_shape[1]), spatial(output_shape[4], output_shape[3], - output_shape[2]))}; - else - return layout{input_layout.data_type, - input_format, - tensor(batch(output_shape[0]), feature(output_shape[1]), spatial(output_shape[3], output_shape[2]))}; + return layout{input_layout.data_type, input_format, desc->out_size}; } std::string strided_slice_inst::to_string(strided_slice_node const& node) { diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/removing_output_node_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/removing_output_node_test.cpp index c6c2577..2c92475 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/removing_output_node_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/removing_output_node_test.cpp @@ -1,5 +1,5 @@ /* -// Copyright (c) 2019 Intel Corporation +// Copyright (c) 2019-2020 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -74,7 +74,7 @@ TEST(removing_output_node, multiple_outputs) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "shuffle_channels", "input2", "input3", "input4", {}, {}, { 1 }, {})); + topology.add(strided_slice("strided_slice", "shuffle_channels", "input2", "input3", "input4", {}, {}, { 1 }, {}, tensor{6, 1, 1, 1})); std::vector input_vec = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }; std::vector out_vec = { 0.0f, 3.0f, 1.0f, 4.0f, 2.0f, 5.0f }; diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/strided_slice_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/strided_slice_gpu_test.cpp index d1d47d2..51a9a5c 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/strided_slice_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/strided_slice_gpu_test.cpp @@ -1,5 +1,5 @@ /* -// Copyright (c) 2019 Intel Corporation +// Copyright (c) 2019-2020 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x2_full) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, tensor{2, 2, 2, 2})); network network(engine, topology); @@ -116,7 +116,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x2_full) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, tensor{2, 2, 2, 2})); network network(engine, topology); @@ -173,7 +173,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x2_ignore) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, tensor{2, 2, 2, 2})); network network(engine, topology); @@ -232,7 +232,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x2_ignore) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, tensor{2, 2, 2, 2})); network network(engine, topology); @@ -291,7 +291,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x2_single) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, tensor{1})); network network(engine, topology); @@ -347,7 +347,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x2_single) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, tensor{1})); network network(engine, topology); @@ -407,7 +407,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x4x3_stride) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, tensor{2, 2, 3, 2})); network network(engine, topology); @@ -470,7 +470,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x4x3_stride) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, tensor{2, 2, 3, 2})); network network(engine, topology); @@ -546,7 +546,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x4x4_part_stride) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {1, 0, 0, 1}, {}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {1, 0, 0, 1}, {}, {}, {}, tensor{1, 2, 2, 4})); network network(engine, topology); @@ -629,7 +629,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x4x4_part_stride) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {1, 0, 0, 1}, {}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {1, 0, 0, 1}, {}, {}, {}, tensor{1, 2, 2, 4})); network network(engine, topology); @@ -693,7 +693,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x4x1_new_axis_mask) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, { 1 }, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, { 1 }, {}, tensor{2, 2, 1, 4})); network network(engine, topology); @@ -749,7 +749,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x4x1_new_axis_mask) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, { 1 }, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, { 1 }, {}, tensor{2, 2, 1, 4})); network network(engine, topology); @@ -804,7 +804,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x1x1_new_axis_mask_2) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, { 1, 0, 1 }, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, { 1, 0, 1 }, {}, tensor{2, 2, 1, 1})); network network(engine, topology); @@ -858,7 +858,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x1x1_new_axis_mask_2) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, { 1, 0, 1 }, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, { 1, 0, 1 }, {}, tensor{2, 2, 1, 1})); network network(engine, topology); @@ -911,7 +911,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x1x1) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {0,1}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {0,1}, {}, {}, {}, tensor{2, 2, 1, 1})); network network(engine, topology); @@ -964,7 +964,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x1x1) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {0,1}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {0,1}, {}, {}, {}, tensor{2, 2, 1, 1})); network network(engine, topology); @@ -1017,7 +1017,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x1x1) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, tensor{1, 2, 1, 2})); network network(engine, topology); @@ -1070,7 +1070,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x1x1) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, tensor{1, 2, 1, 2})); network network(engine, topology); @@ -1123,7 +1123,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x1x1_2) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, tensor{2, 1, 1, 1})); network network(engine, topology); @@ -1176,7 +1176,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x1x1_2) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, tensor{2, 1, 1, 1})); network network(engine, topology); @@ -1233,7 +1233,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x2_full_negative_stride) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, tensor{2, 2, 2, 2})); network network(engine, topology); @@ -1290,7 +1290,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x2_full_negative_stride) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, tensor{2, 2, 2, 2})); network network(engine, topology); @@ -1343,7 +1343,7 @@ TEST(strided_slice_gpu_f32_i32, test_2x2x2x1x1_2_negative_all) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, tensor{2, 1, 1, 1})); network network(engine, topology); @@ -1396,7 +1396,7 @@ TEST(strided_slice_gpu_f32_i64, test_2x2x2x1x1_2_negative_all) { topology.add(data("input2", begin)); topology.add(data("input3", end)); topology.add(data("input4", strides)); - topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {})); + topology.add(strided_slice("strided_slice", "input", "input2", "input3", "input4", {}, {}, {}, {}, tensor{2, 1, 1, 1})); network network(engine, topology); -- 2.7.4