(self)
| 559 | _op.input.extend([tensor.name]) |
| 560 | |
| 561 | def ensure_binary_input(self): |
| 562 | for _op in self._model.op: |
| 563 | if _op.type != MaceOp.Eltwise.name: |
| 564 | continue |
| 565 | if len(_op.input) != 1: |
| 566 | continue |
| 567 | eltwise_type = ConverterUtil.get_arg( |
| 568 | _op, MaceKeyword.mace_element_type_str).i |
| 569 | if eltwise_type != EltwiseType.SUM.value and \ |
| 570 | eltwise_type != EltwiseType.PROD.value: |
| 571 | continue |
| 572 | |
| 573 | float_value_arg = ConverterUtil.get_arg( |
| 574 | _op, MaceKeyword.mace_scalar_input_str) |
| 575 | mace_check(float_value_arg.f is not None, |
| 576 | _op.name + ': ' + |
| 577 | MaceKeyword.mace_scalar_input_str + |
| 578 | ' value float should not be None') |
| 579 | scalar = float_value_arg.f |
| 580 | const_tensor = self._model.tensors.add() |
| 581 | const_tensor.name = _op.name + '/' + \ |
| 582 | MaceKeyword.mace_scalar_input_str + ':0' |
| 583 | const_tensor.dims.extend([1]) |
| 584 | const_tensor.data_type = _op.output_type[0] |
| 585 | if _op.output_type[0] == mace_pb2.DT_UINT8 or \ |
| 586 | _op.output_type[0] == mace_pb2.DT_INT16: |
| 587 | const_tensor.scale = scalar |
| 588 | const_tensor.zero_point = 0 |
| 589 | const_tensor.quantized = True |
| 590 | const_tensor.int32_data.extend([1]) |
| 591 | elif _op.output_type[0] == mace_pb2.DT_FLOAT: |
| 592 | const_tensor.float_data.extend([scalar]) |
| 593 | _op.input.extend([const_tensor.name]) |
| 594 | ConverterUtil.del_arg( |
| 595 | _op, MaceKeyword.mace_scalar_input_str) |
| 596 | ConverterUtil.del_arg( |
| 597 | _op, MaceKeyword.mace_scalar_input_index_str) |
| 598 | |
| 599 | def use_quant_in_out(self): |
| 600 | replace_dict = {} |
no test coverage detected