2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "backend/IConstantInitializer.h"
28 void IConstantInitializer::registerCopyInitializer(const ir::OperandIndex &index,
29 const ir::Operand &obj)
32 // TODO Add to check if tensor has been allocated
33 if (!obj.isConstant())
36 const auto type = obj.typeInfo().type();
41 case DataType::FLOAT32:
42 _init_map[index] = copyInit<float>;
45 _init_map[index] = copyInit<int32_t>;
47 case DataType::UINT32:
48 _init_map[index] = copyInit<uint32_t>;
51 case DataType::QUANT_UINT8_ASYMM:
52 _init_map[index] = copyInit<uint8_t>;
54 case DataType::QUANT_INT8_SYMM:
55 case DataType::QUANT_INT8_ASYMM:
56 _init_map[index] = copyInit<int8_t>;
58 case DataType::FLOAT16:
59 _init_map[index] = copyInit<float16>;
62 _init_map[index] = copyInit<int64_t>;
65 throw std::runtime_error("Not supported, yet");
70 void IConstantInitializer::registerPermuteInitializer(const ir::OperandIndex &index,
71 const ir::Operand &obj)
74 // TODO Add to check if tensor has been allocated
75 if (!obj.isConstant())
78 const auto type = obj.typeInfo().type();
80 using namespace std::placeholders;
84 case DataType::FLOAT32:
85 _init_map[index] = std::bind(permuteInit<float>, _1, _2, _current_op_seq_layout);
88 _init_map[index] = std::bind(permuteInit<int32_t>, _1, _2, _current_op_seq_layout);
90 case DataType::UINT32:
91 _init_map[index] = std::bind(permuteInit<uint32_t>, _1, _2, _current_op_seq_layout);
94 case DataType::QUANT_UINT8_ASYMM:
95 _init_map[index] = std::bind(permuteInit<uint8_t>, _1, _2, _current_op_seq_layout);
97 case DataType::QUANT_INT8_SYMM:
98 case DataType::QUANT_INT8_ASYMM:
99 _init_map[index] = std::bind(permuteInit<int8_t>, _1, _2, _current_op_seq_layout);
101 case DataType::FLOAT16:
102 _init_map[index] = std::bind(permuteInit<float16>, _1, _2, _current_op_seq_layout);
104 case DataType::INT64:
105 _init_map[index] = std::bind(permuteInit<int64_t>, _1, _2, _current_op_seq_layout);
108 throw std::runtime_error("Not supported, yet");
113 } // namespace backend