2 * Copyright (c) 2023 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_BUTIN_TRAIN_KERNEL_GENERATOR_H__
18 #define __ONERT_BACKEND_BUTIN_TRAIN_KERNEL_GENERATOR_H__
20 #include "../ExternalContext.h"
21 #include "../train/TensorRegistry.h"
22 #include "../../../compiler/train/TensorRegistries.h"
24 #include <backend/train/KernelGeneratorBase.h>
25 #include <exec/train/TrainableFnSequence.h>
26 #include <ir/train/TrainableGraph.h>
37 class KernelGenerator : public backend::train::KernelGeneratorBase
40 KernelGenerator(const ir::train::TrainableGraph &tgraph,
41 const std::shared_ptr<TensorRegistry> &tensor_reg,
42 const std::shared_ptr<ExternalContext> &external_context);
44 std::unique_ptr<exec::train::TrainableFnSequence> generate(ir::OperationIndex ind) override;
46 void setTensorRegistries(const compiler::train::TensorRegistries &tensor_registries)
48 _tensor_registries = tensor_registries;
51 void setWholeGraphOutputs(const ir::OperandIndexSequence &outputs)
53 _whole_graph_outputs = outputs;
57 void visit(const ir::train::operation::Permute &) override;
60 backend::ITensor *getTensor(const ir::OperandIndex &index);
61 backend::ITensor *getDerivativeTensor(const ir::OperandIndex &index);
64 std::shared_ptr<TensorRegistry> _tensor_reg;
65 compiler::train::TensorRegistries _tensor_registries;
66 const std::shared_ptr<ExternalContext> _external_context;
67 ir::OperandIndexSequence _whole_graph_outputs;
71 } // namespace builtin
72 } // namespace backend
75 #endif // __ONERT_BACKEND_BUTIN_TRAIN_KERNEL_GENERATOR_H__