提交 b6b51e36 编写于 作者: Y yejianwu

fix python3 support for hexagon, update docs for docker image

上级 3e795fa3
...@@ -15,18 +15,18 @@ In most cases, the ``lite edition`` image can satisfy developer's basic needs. ...@@ -15,18 +15,18 @@ In most cases, the ``lite edition`` image can satisfy developer's basic needs.
.. code:: sh .. code:: sh
# Pull lite edition docker image # You can pull lite edition docker image from docker repo (recommended)
docker pull registry.cn-hangzhou.aliyuncs.com/xiaomimace/mace-dev-lite docker pull registry.cn-hangzhou.aliyuncs.com/xiaomimace/mace-dev-lite
# Build lite edition docker image # Or build lite edition docker image by yourself
docker build -t registry.cn-hangzhou.aliyuncs.com/xiaomimace/mace-dev-lite ./docker/mace-dev-lite docker build -t registry.cn-hangzhou.aliyuncs.com/xiaomimace/mace-dev-lite ./docker/mace-dev-lite
- ``full edition`` docker image (which contains multiple NDK versions and other dev tools). - ``full edition`` docker image (which contains multiple NDK versions and other dev tools).
.. code:: sh .. code:: sh
# Pull full edition docker image # You can pull full edition docker image from docker repo (recommended)
docker pull registry.cn-hangzhou.aliyuncs.com/xiaomimace/mace-dev docker pull registry.cn-hangzhou.aliyuncs.com/xiaomimace/mace-dev
# Build full edition docker image # Or build full edition docker image by yourself
docker build -t registry.cn-hangzhou.aliyuncs.com/xiaomimace/mace-dev ./docker/mace-dev docker build -t registry.cn-hangzhou.aliyuncs.com/xiaomimace/mace-dev ./docker/mace-dev
.. note:: .. note::
......
...@@ -29,6 +29,8 @@ from mace.python.tools.converter_tool.base_converter import ReduceType ...@@ -29,6 +29,8 @@ from mace.python.tools.converter_tool.base_converter import ReduceType
from mace.python.tools.convert_util import mace_check from mace.python.tools.convert_util import mace_check
from mace.python.tools import graph_util from mace.python.tools import graph_util
from six.moves import reduce
HexagonSupportedOps = [ HexagonSupportedOps = [
'BatchToSpaceND_8', 'BatchToSpaceND_8',
...@@ -126,9 +128,9 @@ class HexagonConverter(base_converter.ConverterInterface): ...@@ -126,9 +128,9 @@ class HexagonConverter(base_converter.ConverterInterface):
self.add_input_output_node() self.add_input_output_node()
if not self._option.check_nodes: if not self._option.check_nodes:
output_name = self._option.output_nodes.values()[0].name output_name = list(self._option.output_nodes.values())[0].name
else: else:
output_name = self._option.check_nodes.values()[0].name output_name = list(self._option.check_nodes.values())[0].name
output_name = normalize_name(output_name) output_name = normalize_name(output_name)
self._model = graph_util.sort_mace_graph(self._model, output_name) self._model = graph_util.sort_mace_graph(self._model, output_name)
...@@ -388,9 +390,9 @@ class HexagonConverter(base_converter.ConverterInterface): ...@@ -388,9 +390,9 @@ class HexagonConverter(base_converter.ConverterInterface):
output_node = None output_node = None
if not self._option.check_nodes: if not self._option.check_nodes:
output_name = self._option.output_nodes.values()[0].name output_name = list(self._option.output_nodes.values())[0].name
else: else:
output_name = self._option.check_nodes.values()[0].name output_name = list(self._option.check_nodes.values())[0].name
output_name = normalize_name(output_name) output_name = normalize_name(output_name)
for op in self._model.op: for op in self._model.op:
if op.name == output_name: if op.name == output_name:
......
...@@ -100,7 +100,7 @@ def cal_multiplier_and_shift(scale): ...@@ -100,7 +100,7 @@ def cal_multiplier_and_shift(scale):
def quantize_with_scale_and_zero(data, scale, zero): def quantize_with_scale_and_zero(data, scale, zero):
output = np.round(zero + data / scale).astype(int) output = np.round(zero + data / scale).astype(np.int32)
quantized_data = QuantizedData() quantized_data = QuantizedData()
quantized_data.data = output quantized_data.data = output
quantized_data.scale = scale quantized_data.scale = scale
...@@ -114,7 +114,7 @@ def quantize(data, non_zero): ...@@ -114,7 +114,7 @@ def quantize(data, non_zero):
in_max = np_data.max() in_max = np_data.max()
scale, zero, out_min, out_max = adjust_range(in_min, in_max, scale, zero, out_min, out_max = adjust_range(in_min, in_max,
non_zero=non_zero) non_zero=non_zero)
output = np.clip((np.round(zero + data / scale).astype(int)), 0, 255) output = np.clip((np.round(zero + data / scale).astype(np.int32)), 0, 255)
quantized_data = QuantizedData() quantized_data = QuantizedData()
quantized_data.data = output quantized_data.data = output
...@@ -132,7 +132,7 @@ def quantize_bias_for_hexagon(data): ...@@ -132,7 +132,7 @@ def quantize_bias_for_hexagon(data):
in_max = max_val in_max = max_val
scale = (in_max - in_min) / 2**32 scale = (in_max - in_min) / 2**32
zero = 0 zero = 0
output = np.clip((np.round(zero + data / scale).astype(long)), output = np.clip((np.round(zero + data / scale).astype(np.int64)),
-2**31, 2**31 - 1) -2**31, 2**31 - 1)
quantized_data = QuantizedData() quantized_data = QuantizedData()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册