14 #include <initializer_list> 29 explicit TensorShape(
unsigned int numDimensions,
bool initDimensionsSpecificity =
true);
34 TensorShape(
unsigned int numDimensions,
const unsigned int* dimensionSizes);
38 TensorShape(std::initializer_list<unsigned int> dimensionSizeList);
48 TensorShape(
unsigned int numDimensions,
const unsigned int* dimensionSizes,
const bool* dimensionsSpecificity);
53 TensorShape(std::initializer_list<unsigned int> dimensionSizeList,
54 std::initializer_list<bool> dimensionsSpecificityList);
102 void SetNumDimensions(
unsigned int numDimensions,
bool initDimensionsSpecificity =
false);
119 std::array<unsigned int, MaxNumOfTensorDimensions> m_Dimensions{};
122 std::array<bool, MaxNumOfTensorDimensions> m_DimensionsSpecificity = { {
true} };
125 unsigned int m_NumDimensions{};
132 void CheckDimensionIndex(
unsigned int i)
const;
136 static void CheckValidNumDimensions(
unsigned int numDimensions) ;
140 void CheckDimensionSpecified(
unsigned int i)
const;
143 void CheckScalar()
const;
146 void CheckUnspecifiedNumDimensions()
const;
149 void CheckSpecifiedNumDimensions()
const;
160 float quantizationScale = 0.0f,
161 int32_t quantizationOffset = 0);
164 const unsigned int* dimensionSizes,
166 float quantizationScale = 0.0f,
167 int32_t quantizationOffset = 0);
171 const std::vector<float>& quantizationScales,
172 unsigned int quantizationDim);
175 const unsigned int* dimensionSizes,
177 const std::vector<float>& quantizationScales,
178 unsigned int quantizationDim);
199 bool HasPerAxisQuantization()
const;
201 std::vector<float> GetQuantizationScales()
const;
202 void SetQuantizationScales(
const std::vector<float>& scales);
204 float GetQuantizationScale()
const;
207 int32_t GetQuantizationOffset()
const;
213 bool IsQuantized()
const;
216 bool IsTypeSpaceMatch(
const TensorInfo& other)
const;
218 unsigned int GetNumBytes()
const;
232 Quantization(
const Quantization& other)
233 : m_Scales(other.m_Scales)
234 , m_Offset(other.m_Offset)
235 , m_QuantizationDim(other.m_QuantizationDim) {}
237 bool operator==(
const Quantization& other)
const 239 return ((m_Scales == other.m_Scales) && (m_Offset == other.m_Offset) &&
240 (m_QuantizationDim == other.m_QuantizationDim));
243 Quantization&
operator=(
const Quantization& other)
247 m_Scales = other.m_Scales;
248 m_Offset = other.m_Offset;
249 m_QuantizationDim = other.m_QuantizationDim;
254 std::vector<float> m_Scales;
263 template<
typename MemoryType>
329 template <
template<
typename,
typename...>
class ContainerType,
typename T,
typename...ContainerArgs >
331 :
BaseTensor<const void*>(info, container.data())
333 if (container.size() *
sizeof(T) != info.
GetNumBytes())
340 using InputTensors = std::vector<std::pair<LayerBindingId, class ConstTensor>>;
unsigned int GetNumElements() const
Function that calculates the tensor elements by multiplying all dimension size which are Specified...
bool operator!=(const TensorShape &other) const
Inequality comparison operator.
unsigned int operator[](unsigned int i) const
Read only operator.
const TensorShape & GetShape() const
TensorShape & operator=(const TensorShape &other)
Assignation function.
bool AreAllDimensionsSpecified() const
Checks if there is at least one dimension not specified.
Dimensionality GetDimensionality() const
Function that returns the tensor type.
boxEncodingsInfo SetQuantizationOffset(1)
const TensorShape & GetShape() const
unsigned int GetNumBytes() const
unsigned int GetNumElements() const
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
MemoryType GetMemoryArea() const
Copyright (c) 2020 ARM Limited.
bool HasMultipleQuantizationScales() const
bool GetDimensionSpecificity(unsigned int i) const
Gets information about if the dimension size has been specified or not.
void SetShape(const TensorShape &newShape)
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
bool operator==(const TensorShape &other) const
Equality comparison operator.
boxEncodingsInfo SetQuantizationScale(1.0f)
TensorShape()
Empty (invalid) constructor.
DataType GetDataType() const
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
void SetNumDimensions(unsigned int numDimensions, bool initDimensionsSpecificity=false)
Sets the tensor rank and therefore the Dimensionality is set to Specified if it was not...
std::vector< std::pair< LayerBindingId, class Tensor > > OutputTensors
const TensorInfo & GetInfo() const
void SetDataType(DataType type)
ConstTensor(const TensorInfo &info, const ContainerType< T, ContainerArgs... > &container)
Constructor from a backing container.
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
std::pair< armnn::LayerBindingId, armnn::TensorInfo > BindingPointInfo
ConstTensor(const Tensor &other)
Can be implicitly constructed from non-const Tensor.
unsigned int GetNumDimensions() const
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
void SetDimensionSize(unsigned int i, unsigned int dimensionSize)
Sets the size of the indicated dimension and Specificity for that dimension is set to true...
~BaseTensor()
Protected destructor to stop users from making these (could still new one on the heap and then leak i...
DataType GetDataType() const
unsigned int GetNumDimensions() const
bool IsAtLeastOneDimensionSpecified() const
Checks if there is at least one dimension specified.
unsigned int GetNumElements() const
unsigned int GetNumBytes() const