ONE - On-device Neural Engine
Loading...
Searching...
No Matches
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
19namespace onert
20{
21namespace backend
22{
23namespace train
24{
25namespace ops
26{
27
29 : _input{nullptr}, _shape{nullptr}, _output{nullptr}, _back_prop_input{nullptr},
30 _back_prop_output{nullptr}
31{
32 // DO NOTHING
33}
34
35void ReshapeLayer::reshapeGeneric(const IPortableTensor *input, IPortableTensor *output)
36{
37 size_t count = input->total_size();
38 memcpy(output->buffer(), input->buffer(), count);
39}
40
42 IPortableTensor *output)
43{
44 _input = input;
45 /* note : shape is optional. If not provided from model, _shape is nullptr. */
46 _shape = shape;
47 _output = output;
48}
49
51 const IPortableTensor *back_prop_output)
52{
53 _back_prop_input = back_prop_input;
54 _back_prop_output = back_prop_output;
55}
56
57void ReshapeLayer::forward(bool) { reshapeGeneric(_input, _output); }
58
59void ReshapeLayer::backward() { reshapeGeneric(_back_prop_output, _back_prop_input); }
60
61} // namespace ops
62} // namespace train
63} // namespace backend
64} // namespace onert
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