1# Copyright © 2020 Arm Ltd. All rights reserved. 2# SPDX-License-Identifier: MIT 3import pyarmnn as ann 4 5 6def test_tensor_info_ctor_shape(): 7 tensor_shape = ann.TensorShape((1, 1, 2)) 8 9 tensor_info = ann.TensorInfo(tensor_shape, ann.DataType_QAsymmU8, 0.5, 1) 10 11 assert 2 == tensor_info.GetNumElements() 12 assert 3 == tensor_info.GetNumDimensions() 13 assert ann.DataType_QAsymmU8 == tensor_info.GetDataType() 14 assert 0.5 == tensor_info.GetQuantizationScale() 15 assert 1 == tensor_info.GetQuantizationOffset() 16 17 shape = tensor_info.GetShape() 18 19 assert 2 == shape.GetNumElements() 20 assert 3 == shape.GetNumDimensions() 21 22 23def test_tensor_info__str__(): 24 tensor_info = ann.TensorInfo(ann.TensorShape((2, 3)), ann.DataType_QAsymmU8, 0.5, 1, True) 25 26 assert tensor_info.__str__() == "TensorInfo{DataType: 2, IsQuantized: 1, QuantizationScale: 0.500000, " \ 27 "QuantizationOffset: 1, IsConstant: 1, NumDimensions: 2, NumElements: 6}" 28