8.1.1.2.1.4.1.1. blueoil.converter.plugins.tf

Module for protocol buffer.

8.1.1.2.1.4.1.1.1. Module Contents

8.1.1.2.1.4.1.1.1.1. Classes

Node

Input

Output

Importer

blueoil.converter.plugins.tf.DLK_DTYPE_MAP :Dict[str, Optional[DataType]]
blueoil.converter.plugins.tf.DLK_OPERATOR_MAP :Dict[str, str]
blueoil.converter.plugins.tf.FLOAT32_TENSOR_TYPES
class blueoil.converter.plugins.tf.Node(op_nd)

Bases: object

property name(self) → str

Return the name corresponding to the node.

property node_def_object(self)

Return node object.

property op_type(self) → str

Return the op type of the node.

property inputs(self) → List[str]

Return the name of corresponding inputs to the node.

property tensor_type(self)

Get tensor type info.

get_dtype(self)

Get dlk dtype of the node.

get_shapes(self) → List[List[int]]

Get the output shapes info.

get_shape(self) → List[int]

Get the output shape info.

get_format(self)

Get the output data format info.

list_attributes(self)

Return the attribute list corresponding to the node.

attribute(self, attr_name: str) → Any

Return the attributes data corresponding to the node.

class blueoil.converter.plugins.tf.Input(in_nd)

Bases: object

_TF_TO_NP
DATA_TYPE_MAP
property name(self) → str

Return the name of the node.

property op_type(self) → str

Return the op type of the node.

property nodedef_object(self)

Return node def object.

property is_placeholder(self)

Check op is place holder or not.

get_dtype(self)

Get data type info.

get_data(self)

Get data in numpy format.

get_shape(self) → List[str]

Get shape info.

abstract set_shape(self, val: List[str]) → None

Set shape info.

class blueoil.converter.plugins.tf.Output(out_nd)

Bases: object

property name(self) → str

Return the name corresponding to the node.

property op_type(self) → str

Return the name corresponding to the node.

property inputs(self) → List[str]

Return the name of corresponding inputs to the node.

property node_def_object(self)

Return node object.

property tensor_type(self)

Get shape info.

get_dtype(self)

Get data type info.

get_shape(self) → List[str]

Get shape info.

abstract set_shape(self, val: List[str]) → None

Set shape info.

class blueoil.converter.plugins.tf.Importer(tf_mp)

Bases: object

classmethod make_graph(cls, tf_mp) → Graph
validate_tf(self) → None

Validate if the GraphDef object is proper.

convert_operator(self, op_type: str) → str

Convert Tensorflow operator type to DLK’s one.

create_new_op(self, node: Any, op_dic: Dict[str, Operator], current_format: str, input_format_list: List[str], nodes_to_remove) → List[Operator]

Create new operators with Node, Input(Constant), Output.

add_all_nodes(self, graph: Graph) → None
_get_format(self, node: Any, output_format: str) → Tuple[str, List[str]]

Get the dimension format, like ‘NCHW’, ‘HWIO’, ‘NHWC’, etc for operators. Always use the format from tensorflow, if the layout format is not defined, then propagate the format from the output. Special case such as: - ‘Conv’: by default of tensorflow, input is ‘NHWC’, and kernel ‘HWIO’ https://www.tensorflow.org/api_docs/python/tf/nn/conv2d - ‘BinaryMeanScalingQuantizer’, ‘BinaryChannelWiseMeanScalingQuantizer’: kernel quantizer is also in HWIO - ‘Transpose’: depending on the permutation attribute

add_node_to_graph_recursive(self, current: Any, graph: Graph, visited: Set[Any], added: Dict[str, Operator], data_format: str, nodes_to_remove) → List[Operator]
construct_input_hash_table(self, node_list: List[Any], out_list: List[Any], input_list: List[Any]) → Dict[str, Any]
find_inputs(self, node: Any) → List[Any]
create_new_node(self, node: Node, op_dic: Dict[str, Operator], current_format: str, input_format_list: List[str], nodes_to_remove) → List[Operator]

Create a new operator node. This might be tooooo long code…

Parameters
  • node (Node) – TF node corresponding to the operator

  • op_dic (dict) – Dict of preceding operators

  • current_format (dict) – Dict of data format of current node

  • input_format_list (dict) – Dict of data format of corresponding inputs of current node

Returns

Newly created dlk operator

Return type

Operator