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,
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);
203 bool HasPerAxisQuantization()
const;
205 std::vector<float> GetQuantizationScales()
const;
206 void SetQuantizationScales(
const std::vector<float>& scales);
208 float GetQuantizationScale()
const;
209 void SetQuantizationScale(
float scale);
211 int32_t GetQuantizationOffset()
const;
212 void SetQuantizationOffset(int32_t offset);
217 bool IsQuantized()
const;
219 bool IsConstant()
const;
225 void SetConstant(
const bool IsConstant=
true);
228 bool IsTypeSpaceMatch(
const TensorInfo& other)
const;
230 unsigned int GetNumBytes()
const;
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;
276 template<
typename MemoryType>
334 this->GetInfo().SetConstant();
344 if (!this->GetInfo().IsConstant())
347 "from Tensor due to non-constant TensorInfo");
359 template <
template<
typename,
typename...>
class ContainerType,
typename T,
typename...ContainerArgs >
361 :
BaseTensor<const void*>(info, container.data())
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>>;
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.
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) 2021 ARM Limited and Contributors.
ConstTensor(const TensorInfo &info, MemoryType memoryArea)
ConstTensor constructed from TensorInfo and MemoryType template (a raw memory pointer).
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.
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)
ConstTensor 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