summaryrefslogtreecommitdiff
path: root/tools/python
diff options
context:
space:
mode:
authorGuo, Yejun <yejun.guo@intel.com>2019-09-20 11:55:48 +0800
committerPedro Arthur <bygrandao@gmail.com>2019-09-20 10:57:18 -0300
commitb2683c66b215ee3b67628880b93f7371d21bc946 (patch)
tree09eb095217f31f5ff83ba1b6d07472e9f88a4423 /tools/python
parentea673a0edb4b32cab54344faedb41bc3473730eb (diff)
libavfilter/dnn: add layer maximum for native mode.
The reason to add this layer is that it is used by srcnn in vf_sr. This layer is currently ignored in native mode. After this patch, we can add multiple outputs support for native mode. Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
Diffstat (limited to 'tools/python')
-rw-r--r--tools/python/convert_from_tensorflow.py17
-rw-r--r--tools/python/convert_header.py2
2 files changed, 17 insertions, 2 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):
diff --git a/tools/python/convert_header.py b/tools/python/convert_header.py
index 6a7e4af0c9..3c2acd5b15 100644
--- a/tools/python/convert_header.py
+++ b/tools/python/convert_header.py
@@ -23,4 +23,4 @@ str = 'FFMPEGDNNNATIVE'
major = 0
# increase minor when we don't have to re-convert the model file
-minor = 1
+minor = 2