blob: e54e2a998c1a84600f016bc46541841c207c511e [file] [log] [blame]
Richard Burtondc0c6ed2020-04-08 16:39:05 +01001# 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__():
Cathal Corbett5b8093c2021-10-22 11:12:07 +010024 tensor_info = ann.TensorInfo(ann.TensorShape((2, 3)), ann.DataType_QAsymmU8, 0.5, 1, True)
Richard Burtondc0c6ed2020-04-08 16:39:05 +010025
26 assert tensor_info.__str__() == "TensorInfo{DataType: 2, IsQuantized: 1, QuantizationScale: 0.500000, " \
Cathal Corbett5b8093c2021-10-22 11:12:07 +010027 "QuantizationOffset: 1, IsConstant: 1, NumDimensions: 2, NumElements: 6}"