2 * Copyright (c) 2021 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 #ifndef __LUCI_PASS_HELPERS_TYPE_MAPPER_H__
18 #define __LUCI_PASS_HELPERS_TYPE_MAPPER_H__
20 #include <loco/IR/DataType.h>
28 * @brief TypeMapper maps between c++ primitive data type and loco::DataType.
30 template <typename T> struct TypeMapper
32 static constexpr loco::DataType get() { return loco::DataType::Unknown; }
35 template <> struct TypeMapper<float>
37 static constexpr loco::DataType get() { return loco::DataType::FLOAT32; }
40 template <> struct TypeMapper<uint8_t>
42 static constexpr loco::DataType get() { return loco::DataType::U8; }
45 template <> struct TypeMapper<uint16_t>
47 static constexpr loco::DataType get() { return loco::DataType::U16; }
50 template <> struct TypeMapper<uint32_t>
52 static constexpr loco::DataType get() { return loco::DataType::U32; }
55 template <> struct TypeMapper<uint64_t>
57 static constexpr loco::DataType get() { return loco::DataType::U64; }
60 template <> struct TypeMapper<int8_t>
62 static constexpr loco::DataType get() { return loco::DataType::S8; }
65 template <> struct TypeMapper<int16_t>
67 static constexpr loco::DataType get() { return loco::DataType::S16; }
70 template <> struct TypeMapper<int32_t>
72 static constexpr loco::DataType get() { return loco::DataType::S32; }
75 template <> struct TypeMapper<int64_t>
77 static constexpr loco::DataType get() { return loco::DataType::S64; }
82 #endif // __LUCI_PASS_HELPERS_TYPE_MAPPER_H__