summaryrefslogtreecommitdiff
path: root/compiler/mir-onnx-importer/Op/AveragePool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/mir-onnx-importer/Op/AveragePool.cpp')
-rw-r--r--compiler/mir-onnx-importer/Op/AveragePool.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/compiler/mir-onnx-importer/Op/AveragePool.cpp b/compiler/mir-onnx-importer/Op/AveragePool.cpp
new file mode 100644
index 000000000..9aac33e27
--- /dev/null
+++ b/compiler/mir-onnx-importer/Op/AveragePool.cpp
@@ -0,0 +1,49 @@
+/*
+ * 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 "AveragePool.h"
+
+#include "ONNXHelpers.h"
+
+#include "mir/ops/PoolOp.h"
+
+namespace mir_onnx
+{
+
+std::vector<mir::Operation::Output *>
+AveragePoolNodeConverter::convert(const onnx::NodeProto &onnx_node,
+ const std::vector<mir::Operation::Output *> &inputs,
+ mir::Graph *graph) const
+{
+ // TODO Set some asserts
+ mir::ops::PoolOp::BorderType border_type;
+ mir::ops::PoolOp::PoolingType pool_type;
+
+ KernelStridesPadding cdata;
+ // Transpose ONNX NCHW to MIR NHWC
+ auto t_input = convertONNXToMIR(graph, inputs[0]);
+
+ border_type = mir::ops::PoolOp::BorderType::ZEROFILLED;
+ pool_type = mir::ops::PoolOp::PoolingType::AVG;
+ getKernelStridesPadding(onnx_node, cdata);
+
+ auto result =
+ createOp<mir::ops::PoolOp>(graph, t_input, pool_type, cdata.kernel_shape, cdata.strides_shape,
+ cdata.padding_before, cdata.padding_after, border_type);
+ return {convertMIRToONNX(graph, result->getOutput(0))};
+}
+
+} // namespace mir_onnx