2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __ONERT_BACKEND_IKERNEL_GENERATOR_H__
18 #define __ONERT_BACKEND_IKERNEL_GENERATOR_H__
24 #include "ITensorBuilder.h"
25 #include "ir/OperationVisitor.h"
26 #include "ir/OpSequence.h"
28 #include "exec/FunctionSequence.h"
35 class IKernelGenerator : public ir::OperationVisitor
38 virtual ~IKernelGenerator() = default;
40 std::unique_ptr<exec::IFunction> releaseFunction()
43 return std::move(_return_fn);
46 std::unique_ptr<exec::FunctionSequence> generate(const ir::OpSequence &op_seq)
49 return std::move(_return_fn_seq);
53 using OperationVisitor::visit;
55 void visit(const ir::OpSequence &) override
57 throw std::runtime_error("KernelGenerator: NYI for operation 'OpSequence'");
60 #define OP(InternalName) \
61 void visit(const ir::operation::InternalName &) override \
63 throw std::runtime_error("KernelGenerator: NYI for operation '" #InternalName "'"); \
65 #include "ir/Operations.lst"
69 std::unique_ptr<exec::IFunction> _return_fn;
70 std::unique_ptr<exec::FunctionSequence> _return_fn_seq; // TODO Extract this out
73 } // namespace backend
76 #endif // __ONERT_BACKEND_IKERNEL_GENERATOR_H__