summaryrefslogtreecommitdiff
path: root/runtime/onert/core/src/ir/DataType.cc
blob: 07670c720814ba91af2bbb5e95d814c0c59bcd3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "ir/DataType.h"

#include <stdexcept>
#include <Half.h>

using float16 = Half;

namespace onert
{
namespace ir
{

size_t sizeOfDataType(DataType data_type)
{
  switch (data_type)
  {
    case DataType::FLOAT32:
      return sizeof(float);
    case DataType::INT32:
      return sizeof(int32_t);
    case DataType::UINT32:
      return sizeof(uint32_t);
    case DataType::BOOL8:
    case DataType::QUANT_UINT8_ASYMM:
    case DataType::UINT8:
      return sizeof(uint8_t);
    case DataType::QUANT_INT8_SYMM:
    case DataType::QUANT_INT8_ASYMM:
    case DataType::QUANT_INT8_SYMM_PER_CHANNEL:
      return sizeof(int8_t);
    case DataType::FLOAT16:
      return sizeof(float16);
    case DataType::INT64:
      return sizeof(int64_t);
    case DataType::QUANT_INT16_ASYMM:
      return sizeof(int16_t);
    case DataType::QUANT_INT16_SYMM:
      return sizeof(int16_t);
    default:
      throw std::runtime_error{"Unsupported type size"};
  }
}

} // namespace ir
} // namespace onert