[mir_onnx] Remove Scale converter (#6633)
authorСергей Баранников/AI Tools Lab /SRR/Engineer/삼성전자 <s.barannikov@samsung.com>
Thu, 15 Aug 2019 18:40:22 +0000 (03:40 +0900)
committerAlexander Efimov/AI Tools Lab/./Samsung Electronics <a.efimov@samsung.com>
Thu, 15 Aug 2019 18:40:22 +0000 (21:40 +0300)
This operation is not a part of the ONNX specification. It is probably a copy&paste from the Caffe2 importer.

Signed-off-by: Sergei Barannikov <s.barannikov@samsung.com>
compiler/mir-onnx-importer/CMakeLists.txt
compiler/mir-onnx-importer/ONNXHelpers.h
compiler/mir-onnx-importer/ONNXOpRegistration.h
compiler/mir-onnx-importer/Op/Scale.cpp [deleted file]
compiler/mir-onnx-importer/Op/Scale.h [deleted file]

index 4cc01d0..7e7072d 100644 (file)
@@ -45,8 +45,6 @@ set(MIR_ONNX_IMPORTER_SOURCES
         Op/Relu.h
         Op/Reshape.cpp
         Op/Reshape.h
-        Op/Scale.cpp
-        Op/Scale.h
         Op/Shape.cpp
         Op/Shape.h
         Op/Sigmoid.cpp
index c6d0441..ef00f43 100644 (file)
@@ -76,14 +76,6 @@ inline float getFloatAttribute(const onnx::NodeProto &onnx_node, const std::stri
   return result->f();
 }
 
-// Create vector tensor filled with the given value
-// TODO Remove.
-inline mir::TensorVariant createScalarTensor(float value, const mir::Shape &shape)
-{
-  std::vector<float> values(static_cast<std::size_t>(shape.numElements()), value);
-  return mir::TensorVariant(mir::DTYPE::FLOAT32, {shape.numElements()}, values.data());
-}
-
 struct KernelStridesPadding
 {
   mir::Shape kernel_shape;
index 1028478..cdb0a78 100644 (file)
@@ -33,7 +33,6 @@
 #include "Op/Pad.h"
 #include "Op/Relu.h"
 #include "Op/Reshape.h"
-#include "Op/Scale.h"
 #include "Op/Shape.h"
 #include "Op/Sigmoid.h"
 #include "Op/Softmax.h"
@@ -66,7 +65,6 @@ inline void registerSupportedOps()
   registry.registerConverter("Pad", stdex::make_unique<PadNodeConverter>());
   registry.registerConverter("Relu", stdex::make_unique<ReluNodeConverter>());
   registry.registerConverter("Reshape", stdex::make_unique<ReshapeNodeConverter>());
-  registry.registerConverter("Scale", stdex::make_unique<ScaleNodeConverter>());
   registry.registerConverter("Shape", stdex::make_unique<ShapeNodeConverter>());
   registry.registerConverter("Sigmoid", stdex::make_unique<SigmoidNodeConverter>());
   registry.registerConverter("Softmax", stdex::make_unique<SoftmaxNodeConverter>());
diff --git a/compiler/mir-onnx-importer/Op/Scale.cpp b/compiler/mir-onnx-importer/Op/Scale.cpp
deleted file mode 100644 (file)
index 655d67d..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "Scale.h"
-
-#include "ONNXHelpers.h"
-
-#include "mir/ops/MulOp.h"
-#include "mir/ops/ConstantOp.h"
-
-namespace mir_onnx
-{
-
-std::vector<mir::Operation::Output *>
-ScaleNodeConverter::convert(const onnx::NodeProto &onnx_node,
-                            const std::vector<mir::Operation::Output *> &inputs,
-                            mir::Graph *graph) const
-{
-  // 1.0f is the default scale factor
-  float scale_val = getFloatAttribute(onnx_node, "scale", 1.0f);
-  const auto &shape = inputs[0]->getShape();
-  auto scale_tensor = createScalarTensor(scale_val, shape);
-  auto scale = createOp<mir::ops::ConstantOp>(graph, scale_tensor)->getOutput(0);
-  auto result = createOp<mir::ops::MulOp>(graph, inputs[0], scale)->getOutput(0);
-  return {result};
-}
-
-} // namespace mir_onnx
diff --git a/compiler/mir-onnx-importer/Op/Scale.h b/compiler/mir-onnx-importer/Op/Scale.h
deleted file mode 100644 (file)
index 55c2e3a..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ONNXNodeConverterRegistry.h"
-
-namespace mir_onnx
-{
-
-class ScaleNodeConverter : public NodeConverter
-{
-public:
-  std::vector<mir::Operation::Output *> convert(const onnx::NodeProto &onnx_node,
-                                                const std::vector<mir::Operation::Output *> &inputs,
-                                                mir::Graph *graph) const override;
-};
-
-} // namespace mir_onnx