Imported Upstream version 1.4.0
[platform/core/ml/nnfw.git] / runtime / onert / backend / cpu / kernel / PermuteLayer.cc
1 /*
2  * Copyright (c) 2018 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 "PermuteLayer.h"
18
19 namespace onert
20 {
21 namespace backend
22 {
23 namespace cpu
24 {
25 namespace kernel
26 {
27
28 using Type = ir::operation::Permute::Type;
29
30 void PermuteLayer::configure(std::shared_ptr<backend::ITensor> input,
31                              std::shared_ptr<backend::ITensor> output,
32                              const ir::Shape &output_shape, Type type, ir::DataType dataType)
33 {
34   _input = input;
35   _output = output;
36   _output_shape = output_shape;
37   _type = type;
38   _dataType = dataType;
39 }
40
41 void PermuteLayer::run()
42 {
43   using ir::DataType;
44   switch (_dataType)
45   {
46     case DataType::FLOAT32:
47       runTempl<float>();
48       break;
49     case DataType::INT32:
50       runTempl<int32_t>();
51       break;
52     case DataType::UINT32:
53       runTempl<uint32_t>();
54       break;
55     case DataType::BOOL8:
56     case DataType::QUANT8_ASYMM:
57       runTempl<uint8_t>();
58       break;
59     case DataType::QUANT8_SYMM:
60       runTempl<int8_t>();
61       break;
62     default:
63       throw std::runtime_error("NYI");
64       break;
65   }
66 }
67
68 } // namespace kernel
69 } // namespace cpu
70 } // namespace backend
71 } // namespace onert