self.conv2d_scope_names = set()
self.conv2d_scopename_inputname_dict = {}
self.op2code = {'Conv2D':1, 'DepthToSpace':2, 'MirrorPad':3, 'Maximum':4, 'MathBinary':5}
- self.mathbin2code = {'Sub':0}
+ self.mathbin2code = {'Sub':0, 'Add':1}
self.mirrorpad_mode = {'CONSTANT':0, 'REFLECT':1, 'SYMMETRIC':2}
self.name_operand_dict = {}
np.array([input_operand_index, output_operand_index], dtype=np.uint32).tofile(f)
- def dump_sub_to_file(self, node, f):
- assert(node.op == 'Sub')
+ def dump_mathbinary_to_file(self, node, f):
self.layer_number = self.layer_number + 1
self.converted_nodes.add(node.name)
i0_node = self.name_node_dict[node.input[0]]
np.array([self.op2code['MathBinary'], self.mathbin2code[node.op]], dtype=np.uint32).tofile(f)
if i0_node.op == 'Const':
scalar = i0_node.attr['value'].tensor.float_val[0]
- assert(i0_node.name.find('sub/x'))
- np.array([1], dtype=np.uint32).tofile(f)
+ np.array([1], dtype=np.uint32).tofile(f) # broadcast: 1
np.array([scalar], dtype=np.float32).tofile(f)
- np.array([0], dtype=np.uint32).tofile(f)
+ np.array([0], dtype=np.uint32).tofile(f) # broadcast: 0
input_operand_index = self.add_operand(i1_node.name, Operand.IOTYPE_INPUT)
np.array([input_operand_index], dtype=np.uint32).tofile(f)
elif i1_node.op == 'Const':
scalar = i1_node.attr['value'].tensor.float_val[0]
- assert(i1_node.name.find('sub/y'))
np.array([0], dtype=np.uint32).tofile(f)
input_operand_index = self.add_operand(i0_node.name, Operand.IOTYPE_INPUT)
np.array([input_operand_index], dtype=np.uint32).tofile(f)
elif node.op == 'Maximum':
self.dump_maximum_to_file(node, f)
elif node.op == 'Sub':
- self.dump_sub_to_file(node, f)
+ self.dump_mathbinary_to_file(node, f)
+ elif node.op == 'Add':
+ self.dump_mathbinary_to_file(node, f)
def dump_operands_to_file(self, f):