23.02
|
Go to the documentation of this file.
13 #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,
162 bool isConstant =
false);
165 const unsigned int* dimensionSizes,
167 float quantizationScale = 0.0f,
168 int32_t quantizationOffset = 0,
169 bool isConstant =
false);
173 const std::vector<float>& quantizationScales,
174 unsigned int quantizationDim,
175 bool isConstant =
false);
178 const unsigned int* dimensionSizes,
180 const std::vector<float>& quantizationScales,
181 unsigned int quantizationDim,
182 bool isConstant =
false);
242 , m_Offset(EmptyOptional())
243 , m_QuantizationDim(EmptyOptional()) {}
245 Quantization(
const Quantization& other)
246 : m_Scales(other.m_Scales)
247 , m_Offset(other.m_Offset)
248 , m_QuantizationDim(other.m_QuantizationDim) {}
250 bool operator==(
const Quantization& other)
const
252 return ((m_Scales == other.m_Scales) && (m_Offset == other.m_Offset) &&
253 (m_QuantizationDim == other.m_QuantizationDim));
256 Quantization&
operator=(
const Quantization& other)
260 m_Scales = other.m_Scales;
261 m_Offset = other.m_Offset;
262 m_QuantizationDim = other.m_QuantizationDim;
267 std::vector<float> m_Scales;
268 Optional<int32_t> m_Offset;
269 Optional<unsigned int> m_QuantizationDim;
276 template<
typename MemoryType>
344 if (!this->
GetInfo().IsConstant())
347 "from Tensor due to non-constant TensorInfo");
359 template <
template<
typename,
typename...>
class ContainerType,
typename T,
typename...ContainerArgs >
363 if (!this->
GetInfo().IsConstant())
367 if (container.size() *
sizeof(T) !=
info.GetNumBytes())
381 template<
typename MemoryType>
385 if (!this->
GetInfo().IsConstant())
392 using InputTensors = std::vector<std::pair<LayerBindingId, class ConstTensor>>;
BaseTensor & operator=(const BaseTensor &)
Tensors are copyable.
int32_t GetQuantizationOffset() const
float GetQuantizationScale() const
void SetDataType(DataType type)
unsigned int operator[](unsigned int i) const
Read only operator.
Dimensionality GetDimensionality() const
Function that returns the tensor type.
void SetQuantizationScale(float scale)
unsigned int GetNumElements() const
Function that calculates the tensor elements by multiplying all dimension size which are Specified.
bool operator==(const TensorInfo &other) const
ConstTensor(const TensorInfo &info, MemoryType memoryArea)
ConstTensor constructed from TensorInfo and MemoryType template (a raw memory pointer).
bool operator!=(const TensorInfo &other) const
TensorInfo & operator=(const TensorInfo &other)
unsigned int GetNumDimensions() const
bool operator!=(const TensorShape &other) const
Inequality comparison operator.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
void SetQuantizationDim(const Optional< unsigned int > &quantizationDim)
TensorShape & operator=(const TensorShape &other)
Assignation function.
~BaseTensor()
Protected destructor to stop users from making these (could still new one on the heap and then leak i...
void SetConstant(const bool IsConstant=true)
Marks the data corresponding to this tensor info as constant.
bool operator==(const TensorShape &other) const
Equality comparison operator.
Copyright (c) 2021 ARM Limited and Contributors.
void SetQuantizationScales(const std::vector< float > &scales)
void SetNumDimensions(unsigned int numDimensions, bool initDimensionsSpecificity=false)
Sets the tensor rank and therefore the Dimensionality is set to Specified if it was not.
void SetQuantizationOffset(int32_t offset)
TensorShape()
Empty (invalid) constructor.
BaseTensor()
Empty (invalid) constructor.
DataType GetDataType() const
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
unsigned int GetNumDimensions() const
bool GetDimensionSpecificity(unsigned int i) const
Gets information about if the dimension size has been specified or not.
ConstTensor(const TensorInfo &info, const ContainerType< T, ContainerArgs... > &container)
Constructor from a backing container.
bool IsTypeSpaceMatch(const TensorInfo &other) const
Check that the types are the same and, if quantize, that the quantization parameters are the same.
unsigned int GetNumElements() const
bool HasPerAxisQuantization() const
unsigned int GetNumBytes() const
const TensorShape & GetShape() const
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Optional< unsigned int > GetQuantizationDim() const
std::vector< std::pair< LayerBindingId, class Tensor > > OutputTensors
unsigned int GetNumBytes() const
ConstTensor(const Tensor &other)
ConstTensor implicitly constructed from non-const Tensor.
bool HasMultipleQuantizationScales() const
void SetShape(const TensorShape &newShape)
const TensorShape & GetShape() const
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
bool IsAtLeastOneDimensionSpecified() const
Checks if there is at least one dimension specified.
std::vector< float > GetQuantizationScales() const
TensorInfo()
Empty (invalid) constructor.
unsigned int GetNumElements() const
MemoryType GetMemoryArea() const
void SetDimensionSize(unsigned int i, unsigned int dimensionSize)
Sets the size of the indicated dimension and Specificity for that dimension is set to true.
DataType GetDataType() const
bool AreAllDimensionsSpecified() const
Checks if there is at least one dimension not specified.
const TensorInfo & GetInfo() const
std::pair< armnn::LayerBindingId, armnn::TensorInfo > BindingPointInfo