diff options
Diffstat (limited to 'runtime/neurun/core/src/compiler/Linear.h')
-rw-r--r-- | runtime/neurun/core/src/compiler/Linear.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/runtime/neurun/core/src/compiler/Linear.h b/runtime/neurun/core/src/compiler/Linear.h new file mode 100644 index 000000000..e10d03695 --- /dev/null +++ b/runtime/neurun/core/src/compiler/Linear.h @@ -0,0 +1,81 @@ +/* + * 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. + */ + +#ifndef __NEURUN_COMPILER_LINEAR_H__ +#define __NEURUN_COMPILER_LINEAR_H__ + +#include <vector> +#include <memory> + +#include "ir/Subgraphs.h" +#include "backend/ITensorBuilder.h" +#include "ir/Graph.h" +#include "compiler/BackendResolver.h" + +namespace neurun +{ +namespace ir +{ +struct OperationVisitor; +} // namespace ir +} // namespace neurun + +namespace neurun +{ +namespace compiler +{ + +class Linear +{ +public: + struct Element + { + const ir::OpSequence *op_seq; + const ir::operation::LowerInfo *lower_info; + + Element() : op_seq{nullptr}, lower_info{nullptr} {} + + Element(const ir::OpSequence *op_seq, const ir::operation::LowerInfo *lower_info) + : op_seq{op_seq}, lower_info{lower_info} + { + // DO NOTHING + } + }; + +public: + Linear(ir::Graph &graph); + +public: + Linear(const Linear &linear) = delete; + +public: + void accept(ir::OperationVisitor &&visitor) const; + + void planTensors(); + + void iterate(const std::function<void(const Element &element)> &fn) const; + + void generateConstantInitializers(void) const; + +private: + ir::Graph &_graph; + std::vector<Element> _elements; +}; + +} // namespace compiler +} // namespace neurun + +#endif // __NEURUN_COMPILER_LINEAR_H__ |