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 #include "TrainableOperationConverter.h"
19 #include "ir/train/Operations.Include.h"
20 #include "util/Utils.h"
29 TrainableOperationConverter::TrainableOperationConverter(
30 ir::train::TrainableGraph &tgraph, const compiler::train::TrainingInfo *training_info)
31 : UntrainableOperationConverter{tgraph}, _training_info{training_info}
33 // Avoid unused-private-field error
34 UNUSED_RELEASE(_training_info);
37 void TrainableOperationConverter::visit(const ir::operation::Conv2D &node)
39 _return_op = std::make_unique<ir::train::operation::Conv2D>(node);
42 void TrainableOperationConverter::visit(const ir::operation::ElementwiseActivation &node)
44 if (node.param().op_type == ir::operation::ElementwiseActivation::Type::RELU)
46 _return_op = std::make_unique<ir::train::operation::ElementwiseActivation>(node);
50 UntrainableOperationConverter::visit(node);
54 void TrainableOperationConverter::visit(const ir::operation::FullyConnected &node)
56 _return_op = std::make_unique<ir::train::operation::FullyConnected>(node);
59 void TrainableOperationConverter::visit(const ir::operation::Loss &node)
61 _return_op = std::make_unique<ir::train::operation::Loss>(node);
64 void TrainableOperationConverter::visit(const ir::operation::Permute &node)
66 _return_op = std::make_unique<ir::train::operation::Permute>(node);
69 void TrainableOperationConverter::visit(const ir::operation::Pool2D &node)
71 _return_op = std::make_unique<ir::train::operation::Pool2D>(node);
74 void TrainableOperationConverter::visit(const ir::operation::Reshape &node)
76 _return_op = std::make_unique<ir::train::operation::Reshape>(node);
79 void TrainableOperationConverter::visit(const ir::operation::Softmax &node)
81 _return_op = std::make_unique<ir::train::operation::Softmax>(node);
85 } // namespace compiler