ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loss.h
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#ifndef __ONERT_IR_TRAIN_OPERATION_LOSS_H__
18#define __ONERT_IR_TRAIN_OPERATION_LOSS_H__
19
20#include "ir/operation/Loss.h"
22
23#include "ir/train/LossCode.h"
24#include "ir/train/LossInfo.h"
25
27{
28
30{
31private:
33
34public:
35 Loss(const OperationType &operation, const LossInfo &info, ir::OpCode y_pred_op_code);
36
37public:
38 std::unique_ptr<ITrainableOperation> clone() const override;
39 void accept(OperationVisitor &v) const override;
40 void accept(TrainableOperationVisitor &v) const override;
41 bool hasTrainableParameter() const override { return false; }
42 std::string name() const override { return toString(_param.loss_code) + toString(opcode()); };
43
44public:
45 const LossInfo &param() const { return _param; }
46 ir::OpCode y_pred_op_code() const { return _y_pred_op_code; }
47
48private:
49 LossInfo _param;
50 ir::OpCode _y_pred_op_code; // The op code of the last node computing y_pred
51};
52
53} // namespace onert::ir::train::operation
54
55#endif // __ONERT_IR_TRAIN_OPERATION_LOSS_H__
OpCode opcode() const final
Definition Loss.h:40
bool hasTrainableParameter() const override
Definition Loss.h:41
std::string name() const override
Definition Loss.h:42
const LossInfo & param() const
Definition Loss.h:45
void accept(OperationVisitor &v) const override
Definition Loss.cc:29
ir::OpCode y_pred_op_code() const
Definition Loss.h:46
std::unique_ptr< ITrainableOperation > clone() const override
Definition Loss.cc:27
volatile const char info[]
std::string toString(LossCode opcode)
Convert the optimizer code to the name.
Definition LossCode.cc:24