Skip to content

Commit ce4c1c8

Browse files
author
v-shux
committed
Fix bug in binary op
1 parent 620f688 commit ce4c1c8

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

keras2ncnn/keras_converter.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@ def SeparableConv2D_helper(
424424
else:
425425
activation_type = 0
426426

427+
weight_data_size = int(layer['weight']['pointwise_kernel:0'].size)
428+
427429
ncnn_graph_attr = ncnn_helper.dump_args(
428430
'Convolution',
429431
num_output=num_output,
@@ -497,15 +499,15 @@ def Add_helper(
497499
keras_graph_helper,
498500
ncnn_graph_helper,
499501
ncnn_helper):
500-
ncnn_graph_attr = ncnn_helper.dump_args('Eltwise', op_type=1)
502+
ncnn_graph_attr = ncnn_helper.dump_args('BinaryOp', op_type=0, with_scalar=0)
501503

502504
ncnn_graph_helper.node(
503505
layer['layer']['name'],
504506
keras_graph_helper.get_node_inbounds(
505507
layer['layer']['name']))
506508
ncnn_graph_helper.set_node_attr(
507509
layer['layer']['name'], {
508-
'type': 'Eltwise', 'param': ncnn_graph_attr, 'binary': []})
510+
'type': 'BinaryOp', 'param': ncnn_graph_attr, 'binary': []})
509511

510512
def Multiply_helper(
511513
self,
@@ -1090,15 +1092,15 @@ def Maximum_helper(
10901092
keras_graph_helper,
10911093
ncnn_graph_helper,
10921094
ncnn_helper):
1093-
ncnn_graph_attr = ncnn_helper.dump_args('Eltwise', op_type=2)
1095+
ncnn_graph_attr = ncnn_helper.dump_args('BinaryOp', op_type=4, with_scalar=0)
10941096

10951097
ncnn_graph_helper.node(
10961098
layer['layer']['name'],
10971099
keras_graph_helper.get_node_inbounds(
10981100
layer['layer']['name']))
10991101
ncnn_graph_helper.set_node_attr(
11001102
layer['layer']['name'], {
1101-
'type': 'Eltwise', 'param': ncnn_graph_attr, 'binary': []})
1103+
'type': 'BinaryOp', 'param': ncnn_graph_attr, 'binary': []})
11021104

11031105
def TensorFlowOpLayer_helper(
11041106
self,
@@ -1140,7 +1142,7 @@ def TensorFlowOpLayer_helper(
11401142
# 'type': 'MemoryData', 'param': ncnn_graph_attr, 'binary': [[constant['0']]]})
11411143

11421144
# Insert the mul layer
1143-
ncnn_graph_attr = ncnn_helper.dump_args('BinaryOp', op_type=2, with_scalar=constant['0'])
1145+
ncnn_graph_attr = ncnn_helper.dump_args('BinaryOp', op_type=2, with_scalar=1, b=constant['0'])
11441146

11451147
ncnn_graph_helper.node(
11461148
layer['layer']['name'],

keras2ncnn/ncnn_param.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class NcnnParamDispatcher:
1212
'BinaryOp': {
1313
0: {'op_type': 0},
1414
1: {'with_scalar': 0},
15-
# 2: {'b': 0.},
15+
2: {'b': 0.},
1616
},
1717

1818
'Clip': {

0 commit comments

Comments
 (0)