summaryrefslogtreecommitdiff
path: root/runtime/onert/backend/acl_cl/Optimizer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/onert/backend/acl_cl/Optimizer.cc')
-rw-r--r--runtime/onert/backend/acl_cl/Optimizer.cc58
1 files changed, 58 insertions, 0 deletions
diff --git a/runtime/onert/backend/acl_cl/Optimizer.cc b/runtime/onert/backend/acl_cl/Optimizer.cc
new file mode 100644
index 000000000..6ba3143e8
--- /dev/null
+++ b/runtime/onert/backend/acl_cl/Optimizer.cc
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2020 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 "Optimizer.h"
+
+#include "ParentInfo.h"
+
+#include <cassert>
+#include <ir/LoweredGraph.h>
+#include <util/logging.h>
+#include "AclSubTensorAnalyzer.h"
+
+namespace onert
+{
+namespace backend
+{
+namespace acl_cl
+{
+
+Optimizer::Optimizer(BackendContext *context)
+ : _context{context},
+ _tensor_builder{std::dynamic_pointer_cast<TensorBuilder>(context->tensor_builder)}
+{
+ assert(context);
+}
+
+void Optimizer::optimize()
+{
+ // Concat elimination (build subtensor info)
+ {
+ acl_common::AclSubTensorAnalyzer sa{*_context->graph()};
+ for (auto op_info : _context->operation_list())
+ {
+ auto &op = _context->graph()->operations().at(op_info.index);
+ sa.setLayout(op_info.layout);
+ op.accept(sa);
+ }
+
+ _tensor_builder->parent_map(sa.releaseParentMap());
+ }
+}
+
+} // namespace acl_cl
+} // namespace backend
+} // namespace onert