Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 1 | # Copyright © 2020 Arm Ltd. All rights reserved. |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | import pyarmnn as ann |
| 4 | |
| 5 | |
| 6 | def 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 | |
| 23 | def test_tensor_info__str__(): |
Cathal Corbett | 5b8093c | 2021-10-22 11:12:07 +0100 | [diff] [blame] | 24 | tensor_info = ann.TensorInfo(ann.TensorShape((2, 3)), ann.DataType_QAsymmU8, 0.5, 1, True) |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 25 | |
| 26 | assert tensor_info.__str__() == "TensorInfo{DataType: 2, IsQuantized: 1, QuantizationScale: 0.500000, " \ |
Cathal Corbett | 5b8093c | 2021-10-22 11:12:07 +0100 | [diff] [blame] | 27 | "QuantizationOffset: 1, IsConstant: 1, NumDimensions: 2, NumElements: 6}" |