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 #include <loco/IR/DataType.h>
25 * @brief TypeMapper maps between c++ primitive data type and loco::DataType.
27 template <typename T> struct TypeMapper
29 static constexpr loco::DataType get() { return loco::DataType::Unknown; }
32 template <> struct TypeMapper<float>
34 static constexpr loco::DataType get() { return loco::DataType::FLOAT32; }
37 template <> struct TypeMapper<uint8_t>
39 static constexpr loco::DataType get() { return loco::DataType::U8; }
42 template <> struct TypeMapper<uint16_t>
44 static constexpr loco::DataType get() { return loco::DataType::U16; }
47 template <> struct TypeMapper<uint32_t>
49 static constexpr loco::DataType get() { return loco::DataType::U32; }
52 template <> struct TypeMapper<uint64_t>
54 static constexpr loco::DataType get() { return loco::DataType::U64; }
57 template <> struct TypeMapper<int8_t>
59 static constexpr loco::DataType get() { return loco::DataType::S8; }
62 template <> struct TypeMapper<int16_t>
64 static constexpr loco::DataType get() { return loco::DataType::S16; }
67 template <> struct TypeMapper<int32_t>
69 static constexpr loco::DataType get() { return loco::DataType::S32; }
72 template <> struct TypeMapper<int64_t>
74 static constexpr loco::DataType get() { return loco::DataType::S64; }