summaryrefslogtreecommitdiff
path: root/tools/python/convert_from_tensorflow.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/python/convert_from_tensorflow.py')
-rw-r--r--tools/python/convert_from_tensorflow.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tools/python/convert_from_tensorflow.py b/tools/python/convert_from_tensorflow.py
index 1437ad358d..a663b34004 100644
--- a/tools/python/convert_from_tensorflow.py
+++ b/tools/python/convert_from_tensorflow.py
@@ -70,7 +70,7 @@ class TFConverter:
self.converted_nodes = set()
self.conv2d_scope_names = set()
self.conv2d_scopename_inputname_dict = {}
- self.op2code = {'Conv2D':1, 'DepthToSpace':2, 'MirrorPad':3}
+ self.op2code = {'Conv2D':1, 'DepthToSpace':2, 'MirrorPad':3, 'Maximum':4}
self.mirrorpad_mode = {'CONSTANT':0, 'REFLECT':1, 'SYMMETRIC':2}
self.name_operand_dict = {}
@@ -200,6 +200,19 @@ class TFConverter:
np.array([input_operand_index, output_operand_index], dtype=np.uint32).tofile(f)
+ def dump_maximum_to_file(self, node, f):
+ assert(node.op == 'Maximum')
+ self.layer_number = self.layer_number + 1
+ ynode = self.name_node_dict[node.input[1]]
+ y = ynode.attr['value'].tensor.float_val[0]
+ np.array([self.op2code[node.op]], dtype=np.uint32).tofile(f)
+ np.array([y], dtype=np.float32).tofile(f)
+ self.converted_nodes.add(node.name)
+ input_operand_index = self.add_operand(node.input[0], Operand.IOTYPE_INPUT)
+ output_operand_index = self.add_operand(node.name, Operand.IOTYPE_OUTPUT)
+ np.array([input_operand_index, output_operand_index], dtype=np.uint32).tofile(f)
+
+
def dump_layers_to_file(self, f):
for node in self.nodes:
if node.name in self.converted_nodes:
@@ -216,6 +229,8 @@ class TFConverter:
self.dump_depth2space_to_file(node, f)
elif node.op == 'MirrorPad':
self.dump_mirrorpad_to_file(node, f)
+ elif node.op == 'Maximum':
+ self.dump_maximum_to_file(node, f)
def dump_operands_to_file(self, f):