提交 ad1b0aa0 编写于 作者: 李寅

Merge branch 'hexagon' into 'master'

Support elementwise mul for DSP

See merge request !1163
...@@ -44,6 +44,7 @@ HexagonSupportedOps = [ ...@@ -44,6 +44,7 @@ HexagonSupportedOps = [
'QuantizedAvgPool_8', 'QuantizedAvgPool_8',
'QuantizedConcat_8', 'QuantizedConcat_8',
'QuantizedMaxPool_8', 'QuantizedMaxPool_8',
'QuantizedMul_8x8to8',
'QuantizedResizeBilinear_8', 'QuantizedResizeBilinear_8',
'QuantizedSoftmax_8', 'QuantizedSoftmax_8',
'QuantizedSub_8p8to8', 'QuantizedSub_8p8to8',
...@@ -69,7 +70,8 @@ class HexagonOps(object): ...@@ -69,7 +70,8 @@ class HexagonOps(object):
HexagonOp.DepthwiseSupernode_8x8p32to8.name, HexagonOp.DepthwiseSupernode_8x8p32to8.name,
MaceOp.Dequantize.name: HexagonOp.DequantizeOUTPUT_8tof.name, MaceOp.Dequantize.name: HexagonOp.DequantizeOUTPUT_8tof.name,
MaceOp.Eltwise.name: [HexagonOp.QuantizedAdd_8p8to8.name, MaceOp.Eltwise.name: [HexagonOp.QuantizedAdd_8p8to8.name,
HexagonOp.QuantizedSub_8p8to8.name], HexagonOp.QuantizedSub_8p8to8.name,
HexagonOp.QuantizedMul_8x8to8.name],
MaceOp.Identity.name: HexagonOp.Nop.name, MaceOp.Identity.name: HexagonOp.Nop.name,
MaceOp.Quantize.name: HexagonOp.QuantizeINPUT_f_to_8.name, MaceOp.Quantize.name: HexagonOp.QuantizeINPUT_f_to_8.name,
MaceOp.Pooling.name: [HexagonOp.QuantizedAvgPool_8.name, MaceOp.Pooling.name: [HexagonOp.QuantizedAvgPool_8.name,
...@@ -189,6 +191,11 @@ class HexagonConverter(base_converter.ConverterInterface): ...@@ -189,6 +191,11 @@ class HexagonConverter(base_converter.ConverterInterface):
elif op.type == MaceOp.Eltwise.name: elif op.type == MaceOp.Eltwise.name:
self.add_min_max_const_node(op, op.input[0]) self.add_min_max_const_node(op, op.input[0])
self.add_min_max_const_node(op, op.input[1]) self.add_min_max_const_node(op, op.input[1])
element_type = \
ConverterUtil.get_arg(op,
MaceKeyword.mace_element_type_str).i
if element_type == EltwiseType.SUM.value \
or element_type == EltwiseType.SUB.value:
self.add_min_max_const_node( self.add_min_max_const_node(
op, op.output[0], True, True, False) op, op.output[0], True, True, False)
elif op.type == MaceOp.BatchToSpaceND.name \ elif op.type == MaceOp.BatchToSpaceND.name \
...@@ -340,9 +347,11 @@ class HexagonConverter(base_converter.ConverterInterface): ...@@ -340,9 +347,11 @@ class HexagonConverter(base_converter.ConverterInterface):
op.type = HexagonOp.QuantizedAdd_8p8to8.name op.type = HexagonOp.QuantizedAdd_8p8to8.name
elif element_type == EltwiseType.SUB.value: elif element_type == EltwiseType.SUB.value:
op.type = HexagonOp.QuantizedSub_8p8to8.name op.type = HexagonOp.QuantizedSub_8p8to8.name
elif element_type == EltwiseType.PROD.value:
op.type = HexagonOp.QuantizedMul_8x8to8.name
else: else:
mace_check(False, mace_check(False,
"Hexagon does not support eltmentwise %s" "Hexagon does not support elementwise %s"
% EltwiseType(element_type).name) % EltwiseType(element_type).name)
elif op.type == MaceOp.Pooling.name: elif op.type == MaceOp.Pooling.name:
pooling_type_arg = ConverterUtil.get_arg( pooling_type_arg = ConverterUtil.get_arg(
......
...@@ -1911,7 +1911,7 @@ class Transformer(base_converter.ConverterInterface): ...@@ -1911,7 +1911,7 @@ class Transformer(base_converter.ConverterInterface):
- producer_op1.quantize_info[0].minval - producer_op1.quantize_info[0].minval
else: else:
mace_check(False, "Quantized Elementwise only support:" mace_check(False, "Quantized Elementwise only support:"
" SUM and SUB now.") " SUM and SUB without ranges now.")
quantize_info = \ quantize_info = \
self.add_quantize_info(op, minval, maxval) self.add_quantize_info(op, minval, maxval)
self._quantize_activation_info[op.output[0]] = quantize_info self._quantize_activation_info[op.output[0]] = quantize_info
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册