ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Convert.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
3 * Copyright 2017 The TensorFlow Authors. All Rights Reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef __PLIER_TF_CONVERT_H__
19#define __PLIER_TF_CONVERT_H__
20
21#include <loco.h>
23
24#include <tensorflow/core/framework/graph.pb.h>
25
26#include <string>
27
28namespace plier
29{
30namespace tf
31{
32
33bool has_attr(const tensorflow::NodeDef &node, const std::string &attr_name);
34bool has_attrs(const tensorflow::NodeDef &node, const std::vector<std::string> &attr_names);
35
36tensorflow::DataType get_datatype_attr(const tensorflow::NodeDef &node,
37 const std::string &attr_name);
38const tensorflow::TensorShapeProto &get_shape_attr(const tensorflow::NodeDef &node,
39 const std::string &attr_name);
40const tensorflow::TensorProto &get_tensor_attr(const tensorflow::NodeDef &node,
41 const std::string &attr_name);
42const tensorflow::AttrValue_ListValue &get_list_attr(const tensorflow::NodeDef &node,
43 const std::string &attr_name);
44const std::string &get_string_attr(const tensorflow::NodeDef &node, const std::string &attr_name);
45int64_t get_int_attr(const tensorflow::NodeDef &node, const std::string &attr_name);
46float get_float_attr(const tensorflow::NodeDef &node, const std::string &attr_name);
47bool get_bool_attr(const tensorflow::NodeDef &node, const std::string &attr_name);
48
49std::vector<int64_t> as_int64_list(const tensorflow::AttrValue_ListValue &lv);
50
51loco::DataType as_loco_datatype(const tensorflow::DataType dtype);
52
56enum class DataLayout
57{
58 NHWC,
59 NCHW,
60};
61
63DataLayout as_data_layout(const std::string &tf_layout_str);
64
65DataLayout get_data_layout(const tensorflow::NodeDef &node, const std::string &attr_name);
66
72void copy_shape(const tensorflow::TensorShapeProto &tf_shape,
74
75} // namespace tf
76} // namespace plier
77
78#endif // __PLIER_TF_CONVERT_H__
DataType
"scalar" value type
Definition DataType.h:27
bool has_attrs(const tensorflow::NodeDef &node, const std::vector< std::string > &attr_names)
Definition Convert.cpp:35
bool has_attr(const tensorflow::NodeDef &node, const std::string &attr_name)
Definition Convert.cpp:30
bool get_bool_attr(const tensorflow::NodeDef &node, const std::string &attr_name)
Definition Convert.cpp:103
const tensorflow::TensorProto & get_tensor_attr(const tensorflow::NodeDef &node, const std::string &attr_name)
Definition Convert.cpp:61
const std::string & get_string_attr(const tensorflow::NodeDef &node, const std::string &attr_name)
Definition Convert.cpp:79
tensorflow::DataType get_datatype_attr(const tensorflow::NodeDef &node, const std::string &attr_name)
Definition Convert.cpp:43
loco::DataType as_loco_datatype(const tensorflow::DataType dtype)
Definition Convert.cpp:123
DataLayout get_data_layout(const tensorflow::NodeDef &node, const std::string &attr_name)
Definition Convert.cpp:156
std::vector< int64_t > as_int64_list(const tensorflow::AttrValue_ListValue &lv)
Definition Convert.cpp:111
float get_float_attr(const tensorflow::NodeDef &node, const std::string &attr_name)
Definition Convert.cpp:95
int64_t get_int_attr(const tensorflow::NodeDef &node, const std::string &attr_name)
Definition Convert.cpp:87
const tensorflow::TensorShapeProto & get_shape_attr(const tensorflow::NodeDef &node, const std::string &attr_name)
Definition Convert.cpp:52
DataLayout
Class to represent TensorFlow "data_format" attr.
Definition Convert.h:57
DataLayout as_data_layout(const std::string &tf_layout_str)
@ brief Convert TF Data Layout string (e.g., "NHWC") to enum class for programming convenience
Definition Convert.cpp:146
void copy_shape(const tensorflow::TensorShapeProto &tf_shape, nncc::core::ADT::tensor::Shape &to_shape)
Copy shape defined in TensorShapeProto to angkor shape.
Definition Convert.cpp:168
const tensorflow::AttrValue_ListValue & get_list_attr(const tensorflow::NodeDef &node, const std::string &attr_name)
Definition Convert.cpp:70