ONE - On-device Neural Engine
Loading...
Searching...
No Matches
KernelBuilder.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17#include "KernelBuilder.h"
18
19namespace luci_interpreter
20{
21
22void KernelConfigureRegistry::configure_kernel(const circle::Operator *cur_op,
23 circle::BuiltinOperator opcode,
24 BaseRuntimeGraph *runtime_graph) const
25{
26 auto specific_configure_func = get_kernel_configure_func(opcode);
27 if (specific_configure_func == nullptr)
28 assert(false && "Unsupported operator");
29
30 specific_configure_func(cur_op, runtime_graph);
31}
32
33void KernelExecuteRegistry::execute_kernel(const circle::Operator *cur_op,
34 circle::BuiltinOperator opcode,
35 BaseRuntimeGraph *runtime_graph) const
36{
37 auto specific_execute_func = get_kernel_execute_func(opcode);
38 if (specific_execute_func == nullptr)
39 assert(false && "Unsupported operator");
40
41 specific_execute_func(cur_op, runtime_graph);
42}
43
44#ifdef ENABLE_TRAINING
45
46training::Status training::KernelTrainRegistry::train_kernel(
47 const circle::Operator *cur_op, circle::BuiltinOperator opcode, CircleReader *reader,
48 GradientCalculationStorage *gradient_calculation_storage, const TrainingSettings &settings,
49 TrainableWeightStorage *weight_storage, bool is_compute_gradient) const
50{
51 auto specific_train_func = get_kernel_train_func(opcode);
52 if (specific_train_func == nullptr)
53 assert(false && "Unsupported operator");
54
55 return specific_train_func(cur_op, reader, gradient_calculation_storage, settings, weight_storage,
56 is_compute_gradient);
57}
58
59#endif // ENABLE_TRAINING
60
61} // namespace luci_interpreter
Loads Circle file and provides helpers to access attributes.
void configure_kernel(const circle::Operator *cur_op, circle::BuiltinOperator opcode, BaseRuntimeGraph *runtime_graph) const
void execute_kernel(const circle::Operator *cur_op, circle::BuiltinOperator opcode, BaseRuntimeGraph *runtime_graph) const