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_CPU_COMMON_KERNEL_GENERATOR_BASE_H__
18 #define __ONERT_BACKEND_CPU_COMMON_KERNEL_GENERATOR_BASE_H__
24 #include "ir/OperationVisitor.h"
25 #include "ir/OpSequence.h"
27 #include "exec/FunctionSequence.h"
28 #include "backend/ITensorRegistry.h"
37 class KernelGeneratorBase : public ir::OperationVisitor
40 virtual ~KernelGeneratorBase() = default;
42 std::unique_ptr<exec::IFunction> releaseFunction()
45 return std::move(_return_fn);
48 std::unique_ptr<exec::FunctionSequence> generate(const ir::OpSequence &op_seq)
51 return std::move(_return_fn_seq);
55 using OperationVisitor::visit;
57 void visit(const ir::OpSequence &) override
59 throw std::runtime_error("KernelGenerator: NYI for operation 'OpSequence'");
62 #define OP(InternalName) \
63 void visit(const ir::operation::InternalName &) override \
65 throw std::runtime_error("KernelGenerator: NYI for operation '" #InternalName "'"); \
67 #include "ir/Operations.lst"
71 std::unique_ptr<exec::IFunction> _return_fn;
72 std::unique_ptr<exec::FunctionSequence> _return_fn_seq; // TODO Extract this out
75 } // namespace cpu_common
76 } // namespace backend
79 #endif // __ONERT_BACKEND_CPU_COMMON_KERNEL_GENERATOR_BASE_H__