Compute Library
 22.05
TensorDescriptor Class Reference

Tensor Descriptor class. More...

#include <Acl.hpp>

Public Member Functions

 TensorDescriptor (const std::vector< int32_t > &shape, DataType data_type)
 Constructor. More...
 
 TensorDescriptor (const AclTensorDescriptor &desc)
 Constructor. More...
 
const AclTensorDescriptorget () const
 Get underlying C tensor descriptor. More...
 
bool operator== (const TensorDescriptor &other)
 Operator to compare two TensorDescriptor. More...
 

Detailed Description

Tensor Descriptor class.

Structure that contains all the required meta-data to represent a tensor

Definition at line 503 of file Acl.hpp.

Constructor & Destructor Documentation

◆ TensorDescriptor() [1/2]

TensorDescriptor ( const std::vector< int32_t > &  shape,
DataType  data_type 
)
inline

Constructor.

Parameters
[in]shapeShape of the tensor
[in]data_typeData type of the tensor

Definition at line 511 of file Acl.hpp.

512  : _shape(shape), _data_type(data_type)
513  {
514  _cdesc.ndims = _shape.size();
515  _cdesc.shape = _shape.data();
516  _cdesc.data_type = detail::as_cenum<AclDataType>(_data_type);
517  _cdesc.strides = nullptr;
518  _cdesc.boffset = 0;
519  }
int64_t * strides
Strides on each dimension.
Definition: AclTypes.h:196
int32_t ndims
Number or dimensions.
Definition: AclTypes.h:193
int64_t boffset
Offset in terms of bytes for the first element.
Definition: AclTypes.h:197
AclDataType data_type
Tensor Data type.
Definition: AclTypes.h:195
int32_t * shape
Tensor Shape.
Definition: AclTypes.h:194

◆ TensorDescriptor() [2/2]

TensorDescriptor ( const AclTensorDescriptor desc)
inlineexplicit

Constructor.

Parameters
[in]descC-type descriptor

Definition at line 524 of file Acl.hpp.

References AclTensorDescriptor::data_type, AclTensorDescriptor::ndims, and AclTensorDescriptor::shape.

525  {
526  _cdesc = desc;
527  _data_type = detail::as_enum<DataType>(desc.data_type);
528  _shape.reserve(desc.ndims);
529  for(int32_t d = 0; d < desc.ndims; ++d)
530  {
531  _shape.emplace_back(desc.shape[d]);
532  }
533  }
int32_t ndims
Number or dimensions.
Definition: AclTypes.h:193
AclDataType data_type
Tensor Data type.
Definition: AclTypes.h:195
int32_t * shape
Tensor Shape.
Definition: AclTypes.h:194

Member Function Documentation

◆ get()

const AclTensorDescriptor* get ( ) const
inline

Get underlying C tensor descriptor.

Returns
Underlying structure

Definition at line 538 of file Acl.hpp.

Referenced by Activation::Activation(), and Tensor::Tensor().

539  {
540  return &_cdesc;
541  }

◆ operator==()

bool operator== ( const TensorDescriptor other)
inline

Operator to compare two TensorDescriptor.

Parameters
[in]otherThe instance to compare against
Returns
True if two instances have the same shape and data type

Definition at line 548 of file Acl.hpp.

549  {
550  bool is_same = true;
551 
552  is_same &= _data_type == other._data_type;
553  is_same &= _shape.size() == other._shape.size();
554 
555  if(is_same)
556  {
557  for(uint32_t d = 0; d < _shape.size(); ++d)
558  {
559  is_same &= _shape[d] == other._shape[d];
560  }
561  }
562 
563  return is_same;
564  }

The documentation for this class was generated from the following file: