From ed182af8bc31ef50b5b225e0c535bd866c163e01 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=91=D0=B0=D1=80?= =?utf8?q?=D0=B0=D0=BD=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2/AI=20Tools=20Lab=20/S?= =?utf8?q?RR/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Wed, 4 Sep 2019 18:38:37 +0300 Subject: [PATCH] [nnc] Change type of strides argument (#7177) Change the type of `strides` argument of `Conv2D` and `DepthwiseConv2D` operations to `vector`. Signed-off-by: Sergei Barannikov --- compiler/nnc/passes/interpreter/ops/DeConv2D.cpp | 2 +- compiler/nnc/unittests/acl_backend/MIRToDOM.cpp | 12 ++++++------ compiler/nnc/unittests/optimizations/FuseArithmeticOps.cpp | 5 +++-- compiler/nnc/unittests/soft_backend/CPPOperations.cpp | 6 +++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/compiler/nnc/passes/interpreter/ops/DeConv2D.cpp b/compiler/nnc/passes/interpreter/ops/DeConv2D.cpp index 31f743a..dfc864b 100644 --- a/compiler/nnc/passes/interpreter/ops/DeConv2D.cpp +++ b/compiler/nnc/passes/interpreter/ops/DeConv2D.cpp @@ -31,7 +31,7 @@ using namespace mir::ops; std::vector nnc::DeConv2D::operator()() { - const auto &strides = _op.getStrides(); + const Shape &strides = _op.getStrides(); Shape out_shape = _op.getOutputShape(0); auto res = allocate_tensor(out_shape); Tensor res_accesor(res); diff --git a/compiler/nnc/unittests/acl_backend/MIRToDOM.cpp b/compiler/nnc/unittests/acl_backend/MIRToDOM.cpp index 0987267..1eb974b 100644 --- a/compiler/nnc/unittests/acl_backend/MIRToDOM.cpp +++ b/compiler/nnc/unittests/acl_backend/MIRToDOM.cpp @@ -282,13 +282,13 @@ TEST(acl_backend_mir_to_dom, conv2d) { const int32_t channels = 3; mir::Shape kernel_shape{1, 3, 3, channels}; // output Channels, Height, Width, input Channels - mir::Shape strides{1, 1}; mir::TensorVariant kernel_tensor = createTensorVariant(kernel_shape); Graph g; OpConstructor op_generator = - [kernel_tensor, strides](mir::Graph &g, const std::vector &inputs) { - std::vector padding{0, 0}; + [kernel_tensor](mir::Graph &g, const std::vector &inputs) { + vector strides{1, 1}; + vector padding{0, 0}; auto kernel = g.create(kernel_tensor)->getOutput(0); return g.create(inputs[0], kernel, strides, padding, padding); }; @@ -309,13 +309,13 @@ TEST(acl_backend_mir_to_dom, depthwise_conv) { const int32_t channels = 3; mir::Shape kernel_shape{3, 3, channels, 1}; // Height, Width, Channels, Channel multiplier - mir::Shape strides{1, 1}; mir::TensorVariant kernel_tensor = createTensorVariant(kernel_shape); Graph g; OpConstructor op_generator = - [kernel_tensor, strides](mir::Graph &g, const std::vector &inputs) { - std::vector padding{0, 0}; + [kernel_tensor](mir::Graph &g, const std::vector &inputs) { + vector strides{1, 1}; + vector padding{0, 0}; auto kernel = g.create(kernel_tensor)->getOutput(0); return g.create(inputs[0], kernel, strides, padding, padding); }; diff --git a/compiler/nnc/unittests/optimizations/FuseArithmeticOps.cpp b/compiler/nnc/unittests/optimizations/FuseArithmeticOps.cpp index 7b8886c..75cfaac 100644 --- a/compiler/nnc/unittests/optimizations/FuseArithmeticOps.cpp +++ b/compiler/nnc/unittests/optimizations/FuseArithmeticOps.cpp @@ -38,8 +38,9 @@ TEST(OptPass, fuseConvBiasScaleScaleBias) // Create graph: 'input->conv->bias->scale->scale->bias' auto input = g.create(Shape{1, 299, 299, 3}); auto conv_const = g.create(TensorVariant(DataType::FLOAT32, {10, 3, 3, 3})); - std::vector padding{0, 0}; - auto conv = g.create(input->getOutput(0), conv_const->getOutput(0), Shape{1, 1}, + const std::vector strides{1, 1}; + const std::vector padding{0, 0}; + auto conv = g.create(input->getOutput(0), conv_const->getOutput(0), strides, padding, padding); auto bias1_const = g.create(TensorVariant(DataType::FLOAT32, {10})); auto bias1 = g.create(conv->getOutput(0), bias1_const->getOutput(0)); diff --git a/compiler/nnc/unittests/soft_backend/CPPOperations.cpp b/compiler/nnc/unittests/soft_backend/CPPOperations.cpp index 5576a5b..350a3e8 100644 --- a/compiler/nnc/unittests/soft_backend/CPPOperations.cpp +++ b/compiler/nnc/unittests/soft_backend/CPPOperations.cpp @@ -547,7 +547,7 @@ TEST(cpp_operations_test, convTransposed2d) { vector input_shape_data{3, 9, 3, static_cast(input_c)}; // NHWC vector kernel_shape_data{kernel_h, kernel_w, output_c, input_c}; - mir::Shape strides{stride_h, stride_w}; + vector strides{stride_h, stride_w}; vector> input_ntensors(2); Tensor input_atensor0; Tensor input_atensor1; @@ -582,7 +582,7 @@ TEST(cpp_operations_test, conv2d) { vector input_shape_data{3, 5, 7, static_cast(input_c)}; // NHWC vector kernel_shape_data{output_c, kernel_h, kernel_w, input_c}; // OHWI - mir::Shape strides{stride_h, stride_w}; + vector strides{stride_h, stride_w}; vector> input_ntensors(2); Tensor input_atensor0; Tensor input_atensor1; @@ -618,7 +618,7 @@ TEST(cpp_operations_test, depthwise_conv) { vector input_shape_data{3, 7, 6, static_cast(channels)}; // NHWC vector kernel_shape_data{kernel_h, kernel_w, channels, multiplier}; // HWCN - mir::Shape strides{stride_h, stride_w}; + vector strides{stride_h, stride_w}; vector> input_ntensors(2); Tensor input_atensor0; Tensor input_atensor1; -- 2.7.4