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 "luci/Service/CircleTypeInference.h"
20 #include <loco/Service/TypeInference.h>
22 #include <mio/circle/schema_generated.h>
23 #include <oops/InternalExn.h>
25 #include <type_traits>
30 circle::TensorType translateLocoTypeToCircle(loco::DataType dtype)
34 case loco::DataType::U8:
35 return circle::TensorType_UINT8;
36 // case loco::DataType::U16: unsupported
37 // case loco::DataType::U32: unsupported
38 // case loco::DataType::U64: unsupported
39 case loco::DataType::S8:
40 return circle::TensorType_INT8;
41 case loco::DataType::S16:
42 return circle::TensorType_INT16;
43 case loco::DataType::S32:
44 return circle::TensorType_INT32;
45 case loco::DataType::S64:
46 return circle::TensorType_INT64;
47 case loco::DataType::FLOAT16:
48 return circle::TensorType_FLOAT16;
49 case loco::DataType::FLOAT32:
50 return circle::TensorType_FLOAT32;
51 // case loco::DataType::FLOAT64: unsupported
52 case loco::DataType::BOOL:
53 return circle::TensorType_BOOL;
58 INTERNAL_EXN_V("Invalid loco dtype", oops::to_uint32(dtype));
66 circle::TensorType TypeInference::get(loco::Node *node)
68 assert(loco::dtype_known(node));
69 return translateLocoTypeToCircle(loco::dtype_get(node));