ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ReshapeLayer.cc
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#include "ReshapeLayer.h"
18
20{
21
23 : _input{nullptr}, _shape{nullptr}, _output{nullptr}, _back_prop_input{nullptr},
24 _back_prop_output{nullptr}
25{
26 // DO NOTHING
27}
28
29void ReshapeLayer::reshapeGeneric(const IPortableTensor *input, IPortableTensor *output)
30{
31 size_t count = input->total_size();
32 memcpy(output->buffer(), input->buffer(), count);
33}
34
36 IPortableTensor *output)
37{
38 _input = input;
39 /* note : shape is optional. If not provided from model, _shape is nullptr. */
40 _shape = shape;
41 _output = output;
42}
43
45 const IPortableTensor *back_prop_output)
46{
47 _back_prop_input = back_prop_input;
48 _back_prop_output = back_prop_output;
49}
50
51void ReshapeLayer::forward(bool) { reshapeGeneric(_input, _output); }
52
53void ReshapeLayer::backward() { reshapeGeneric(_back_prop_output, _back_prop_input); }
54
55} // namespace onert::backend::train::ops
A tensor class that is portable for other backends.
void configure(const IPortableTensor *input, const IPortableTensor *shape, IPortableTensor *output)
void configureBackward(IPortableTensor *back_prop_input, const IPortableTensor *back_prop_output)
void forward(bool training) override