提交 b6eb7b8a 编写于 作者: L liuqi

Change the float-type const tensor to half type.

上级 2fb96625
......@@ -17,7 +17,7 @@ namespace {{tag}} {
void Create{{tensor.name}}(std::vector<mace::ConstTensor> &tensors) {
tensors.emplace_back(mace::ConstTensor(
{{ tensor.name|tojson }}, {{ tensor.name }},
{ {{ tensor.dims|join(', ') }} }, {{ tensor.data_type }}, {{ tensor.node_id }}));
{ {{ tensor.dims|join(', ') }} }, {{ tensor_info.data_type }}, {{ tensor.node_id }}));
}
} // namespace {{tag}}
......
......@@ -77,9 +77,10 @@ class TensorInfo:
self.name = t.name
self.data_type = mace_pb2.DataType.Name(t.data_type)
if t.data_type == mace_pb2.DT_FLOAT:
self.data = bytearray(struct.pack('%sf' % len(t.float_data), *t.float_data))
self.data_type = mace_pb2.DT_HALF
self.data = bytearray(np.array(t.float_data).astype(np.float16).tobytes())
elif t.data_type == mace_pb2.DT_INT32:
self.data = bytearray(struct.pack('%si' % len(t.int32_data), *t.int32_data))
self.data = bytearray(np.array(t.int32_data).astype(np.int32).tobytes())
elif t.data_type == mace_pb2.DT_UINT8:
self.data = bytearray(np.array(t.int32_data).astype(np.uint8).tolist())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册