24.08
|
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 = 1.0f,
161 int32_t quantizationOffset = 0,
162 bool isConstant =
false);
165 const unsigned int* dimensionSizes,
167 float quantizationScale = 1.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);
244 , m_Offset(EmptyOptional())
245 , m_QuantizationDim(EmptyOptional()) {}
247 Quantization(
const Quantization& other)
248 : m_Scales(other.m_Scales)
249 , m_Offset(other.m_Offset)
250 , m_QuantizationDim(other.m_QuantizationDim) {}
252 bool operator==(
const Quantization& other)
const
254 return ((m_Scales == other.m_Scales) && (m_Offset == other.m_Offset) &&
255 (m_QuantizationDim == other.m_QuantizationDim));
258 Quantization&
operator=(
const Quantization& other)
262 m_Scales = other.m_Scales;
263 m_Offset = other.m_Offset;
264 m_QuantizationDim = other.m_QuantizationDim;
269 std::vector<float> m_Scales;
270 Optional<int32_t> m_Offset;
271 Optional<unsigned int> m_QuantizationDim;
278 template<
typename MemoryType>
346 if (!this->
GetInfo().IsConstant())
349 "from Tensor due to non-constant TensorInfo");
361 template <
template<
typename,
typename...>
class ContainerType,
typename T,
typename...ContainerArgs >
365 if (!this->
GetInfo().IsConstant())
369 if (container.size() *
sizeof(T) !=
info.GetNumBytes())
383 template<
typename MemoryType>
387 if (!this->
GetInfo().IsConstant())
394 using InputTensors = std::vector<std::pair<LayerBindingId, class ConstTensor>>;
std::pair< armnn::LayerBindingId, armnn::TensorInfo > BindingPointInfo
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 SetQuantizationDim(const Optional< unsigned int > &quantizationDim)
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
unsigned int GetNumElements() const
unsigned int GetNumDimensions() const
MemoryType GetMemoryArea() const
unsigned int GetNumBytes() const
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
std::vector< float > GetQuantizationScales() const
bool GetDimensionSpecificity(unsigned int i) const
Gets information about if the dimension size has been specified or not.
float GetQuantizationScale() const
unsigned int GetNumBytes() const
void SetDataType(DataType type)
unsigned int GetNumDimensions() const
bool AreAllDimensionsSpecified() const
Checks if there is at least one dimension not specified.
unsigned int GetNumElements() const
std::vector< std::pair< LayerBindingId, class Tensor > > OutputTensors
unsigned int operator[](unsigned int i) const
Read only operator.
bool HasPerAxisQuantization() const
BaseTensor & operator=(const BaseTensor &)
Tensors are copyable.
std::vector< TensorInfo >::difference_type DifferenceType
DataType GetDataType() const
TensorShape & operator=(const TensorShape &other)
Assignation function.
void SetDimensionSize(unsigned int i, unsigned int dimensionSize)
Sets the size of the indicated dimension and Specificity for that dimension is set to true.
void SetQuantizationScale(float scale)
void SetQuantizationScales(const std::vector< float > &scales)
ConstTensor(const TensorInfo &info, MemoryType memoryArea)
ConstTensor constructed from TensorInfo and MemoryType template (a raw memory pointer).
bool IsAtLeastOneDimensionSpecified() const
Checks if there is at least one dimension specified.
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
BaseTensor()
Empty (invalid) constructor.
Optional< unsigned int > GetQuantizationDim() const
bool HasMultipleQuantizationScales() const
~BaseTensor()
Protected destructor to stop users from making these (could still new one on the heap and then leak i...
bool IsTypeSpaceMatch(const TensorInfo &other) const
Check that the types are the same and, if quantize, that the quantization parameters are the same.
bool operator==(const TensorInfo &other) const
TensorInfo()
Empty (invalid) constructor.
const TensorShape & GetShape() const
bool operator!=(const TensorShape &other) const
Inequality comparison operator.
const TensorInfo & GetInfo() const
bool operator!=(const TensorInfo &other) const
DataType GetDataType() const
TensorInfo & operator=(const TensorInfo &other)
void SetQuantizationOffset(int32_t offset)
const TensorShape & GetShape() const
ConstTensor(const Tensor &other)
ConstTensor implicitly constructed from non-const Tensor.
void SetShape(const TensorShape &newShape)
Copyright (c) 2021 ARM Limited and Contributors.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
bool operator==(const TensorShape &other) const
Equality comparison operator.
void SetConstant(const bool IsConstant=true)
Marks the data corresponding to this tensor info as constant.
int32_t GetQuantizationOffset() const
Dimensionality GetDimensionality() const
Function that returns the tensor type.
unsigned int GetNumElements() const
Function that calculates the tensor elements by multiplying all dimension size which are Specified.
TensorShape()
Empty (invalid) constructor.
ConstTensor(const TensorInfo &info, const ContainerType< T, ContainerArgs... > &container)
Constructor from a backing container.