(self, tensor)
| 2119 | return False |
| 2120 | |
| 2121 | def quantize_large_tensor(self, tensor): |
| 2122 | if tensor.data_type == mace_pb2.DT_FLOAT: |
| 2123 | ops = self._consumers.get(tensor.name, None) |
| 2124 | if ops is not None and len(ops) == 1: |
| 2125 | if ops[0].type in [MaceOp.Conv2D.name, |
| 2126 | MaceOp.FullyConnected.name, |
| 2127 | MaceOp.MatMul.name]: |
| 2128 | quantized_tensor = \ |
| 2129 | quantize_util.quantize(tensor.float_data, |
| 2130 | self._option.device, |
| 2131 | False) |
| 2132 | tensor.data_type = mace_pb2.DT_UINT8 |
| 2133 | |
| 2134 | del tensor.float_data[:] |
| 2135 | tensor.int32_data.extend(quantized_tensor.data) |
| 2136 | tensor.scale = quantized_tensor.scale |
| 2137 | tensor.zero_point = quantized_tensor.zero |
| 2138 | tensor.minval = quantized_tensor.minval |
| 2139 | tensor.maxval = quantized_tensor.maxval |
| 2140 | tensor.quantized = True |
| 2141 | self._quantized_tensor.update([tensor.name]) |
| 2142 | |
| 2143 | def quantize_large_weights(self): |
| 2144 | print("Quantize large weights") |
no test coverage detected