ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
FullyConnectedLayer.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_BACKEND_TRAIN_OPS_FULLYCONNECTEDLAYER_H__
18#define __ONERT_BACKEND_TRAIN_OPS_FULLYCONNECTEDLAYER_H__
19
20#include "../ExternalContext.h"
21#include "../Tensor.h"
22
24#include <ops/FullyConnectedLayer.h>
25
27{
28
31{
32public:
35
36public:
37 void configureBackward(const IPortableTensor *input, const IPortableTensor *weights,
38 IPortableTensor *output, IPortableTensor *back_prop_input,
39 IPortableTensor *grad_weights, IPortableTensor *grad_bias,
40 const IPortableTensor *back_prop_output, ir::Activation activation,
41 ir::FullyConnectedWeightsFormat weights_format);
42
43 void forward(bool training) override;
44 void backward() override;
45
46private:
47 void backwardFloat32();
48
49private:
50 IPortableTensor *_grad_weights;
51 IPortableTensor *_grad_bias;
52 IPortableTensor *_back_prop_input;
53 const IPortableTensor *_back_prop_output;
54
55 // TODO Optimize memory
56 std::unique_ptr<Tensor> _transposed_weights;
57 std::unique_ptr<Tensor> _transposed_input;
58 std::unique_ptr<Tensor> _transposed_back_prop_output;
59 std::unique_ptr<Tensor> _act_back_prop_output;
60};
61
62} // namespace onert::backend::train::ops
63
64#endif // __ONERT_BACKEND_TRAIN_OPS_FULLYCONNECTEDLAYER_H__
A tensor class that is portable for other backends.
void configureBackward(const IPortableTensor *input, const IPortableTensor *weights, IPortableTensor *output, IPortableTensor *back_prop_input, IPortableTensor *grad_weights, IPortableTensor *grad_bias, const IPortableTensor *back_prop_output, ir::Activation activation, ir::FullyConnectedWeightsFormat weights_format)
FullyConnectedWeightsFormat