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 "exec/train/TrainableFnSequence.h"
26 void TrainableFnSequence::forward(bool training)
28 for (const auto &function : _functions)
30 function->forward(training);
34 void TrainableFnSequence::backward(uint32_t training_step)
36 for (auto it = _functions.rbegin(); it != _functions.rend(); ++it)
41 for (const auto &applier : _appliers)
43 applier->applyGradient(training_step);
47 void TrainableFnSequence::append(std::unique_ptr<ITrainableFunction> &&function)
49 _functions.push_back(std::move(function));
52 void TrainableFnSequence::append(std::unique_ptr<IGradientApplier> &&applier)
54 _appliers.push_back(std::move(applier));
57 void TrainableFnSequence::iterate(const std::function<void(ITrainableFunction &)> &fn)
59 for (const auto &func : _functions)