diff options
Diffstat (limited to 'runtimes/neurun/src/compiler/Compiler.cc')
-rw-r--r-- | runtimes/neurun/src/compiler/Compiler.cc | 124 |
1 files changed, 0 insertions, 124 deletions
diff --git a/runtimes/neurun/src/compiler/Compiler.cc b/runtimes/neurun/src/compiler/Compiler.cc deleted file mode 100644 index 92ec69afb..000000000 --- a/runtimes/neurun/src/compiler/Compiler.cc +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2018 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 "Compiler.h" - -#include "OperationValidator.h" -#include "SubTensorAnalyzer.h" -#include "PlanBuilder.h" -#include "ConstantInitializer.h" - -#include "graph/dumper/Dumper.h" -#include "graph/operation/LowerInfo.h" -#include "dumper/dot/DotDumper.h" -#include "linear/Linear.h" - -namespace neurun -{ - -namespace compiler -{ - -void Compiler::compile(void) -{ - auto &plan = this->plan(); - auto &graph = plan.model(); - const auto &operands = graph.operands(); - - // Disable compile phase - // When ready to use interpreter backend, remove this config and use backend setting - const auto env_disable_compile = config::ConfigManager::instance().get<bool>("DISABLE_COMPILE"); - if (env_disable_compile) - { - plan.state(State::NOT_COMPILED); - return; - } - - /*************************************************** - * Backend independent analysis & optimization phase - ***************************************************/ - - /************************************************************* - * Backend independent analysis & optimization phase finished - *************************************************************/ - - // dump graph to .dot - neurun::dumper::dot::DotDumper dot_dumper(graph); - dot_dumper.dumpIfNeeded("before_lower"); - - // Lower: decide backend - graph.lower(); - plan.state(State::LOWERED); - - dot_dumper.dumpIfNeeded("after_lower"); - - auto linear = graph.linearize(); - plan.state(State::LINEARIZED); - - // Dump ops - linear->accept(neurun::graph::dumper::Dumper{}); - - linear->accept(OperationValidator{operands}); - - /************************************************* - * Backend dependent analysis & optimization phase - *************************************************/ - - // SubTensorInfo should be generated after lower, before stage generation and finalize - // because SubTensorAnalyzer assume that insert permutation is already finished - // lower: decide backend and insert permutation - // stage generation: prepare codegen to optimization - // finalize: generate tensor using subtensor info, then execute stage - // Generated SubTensorInfo is in operand(Object) - // for easy pass SubTensorInfo to plan builder and tensor builder - linear->accept(SubTensorAnalyzer{graph.operands()}); - - /********************************************************** - * Backend dependent analysis & optimization phase finished - **********************************************************/ - - /*********************** - * Code generation phase - ***********************/ - - PlanBuilder plan_builder{plan}; - - // Plan building - linear->iterate([&](const linear::Element &element) { - auto backend = element.lower_info->backend(); - - // Generate Stage - auto stage_gen = backend->stage_gen(); - plan_builder.addStage(stage_gen->generate(*element.node)); - }); - - auto tensor_builders = linear->planTensors(); - - // TODO Add optimization passes - plan_builder.finalize(tensor_builders); - - ConstantInitializer{graph, plan}(); - - /******************************** - * Code generation phase finished - ********************************/ - - plan.state(State::COMPILED); -} - -} // namespace compiler - -} // namespace neurun |