Compute Library
TensorPack Class Reference

Tensor packing service. More...

#include <TensorPack.h>

Collaboration diagram for TensorPack:

Public Member Functions

 TensorPack (IContext *ctx)
 Constructor. More...
 ~TensorPack ()
 Destructor. More...
AclStatus add_tensor (ITensorV2 *tensor, int32_t slot_id)
 Add tensor to the pack. More...
size_t size () const
 Pack size accessor. More...
bool empty () const
 Checks if pack is empty. More...
bool is_valid () const
 Checks if an object is valid. More...
arm_compute::ITensorget_tensor (int32_t slot_id)
 Get tensor of a given id from the pac. More...
arm_compute::ITensorPackget_tensor_pack ()
 Get legacy tensor pack. More...

Additional Inherited Members

- Data Fields inherited from AclTensorPack_
arm_compute::detail::Header header { arm_compute::detail::ObjectType::TensorPack, nullptr }

Detailed Description

Tensor packing service.

Class is responsible for creating and managing a collection of tensors. Tensor packs can be passed to operators to be part of the mutable data of the execution.

Definition at line 50 of file TensorPack.h.

Constructor & Destructor Documentation

◆ TensorPack()

TensorPack ( IContext ctx)


[in]ctxContext to be used

Definition at line 30 of file TensorPack.cpp.

References ARM_COMPUTE_ASSERT_NOT_NULLPTR, Header::ctx, AclTensorPack_::header, and IContext::inc_ref().

31  : AclTensorPack_(), _pack()
32 {
34  this->header.ctx = ctx;
35  this->header.ctx->inc_ref();
36 }
arm_compute::detail::Header header
Definition: TensorPack.h:32
void inc_ref() const
Increment context refcount.
Definition: IContext.h:71
Definition: Validate.h:38

◆ ~TensorPack()

~TensorPack ( )


Definition at line 38 of file TensorPack.cpp.

References Header::ctx, IContext::dec_ref(), AclTensorPack_::header, arm_compute::detail::Invalid, and Header::type.

39 {
40  this->header.ctx->dec_ref();
42 }
void dec_ref() const
Decrement context refcount.
Definition: IContext.h:76
arm_compute::detail::Header header
Definition: TensorPack.h:32

Member Function Documentation

◆ add_tensor()

AclStatus add_tensor ( ITensorV2 tensor,
int32_t  slot_id 

Add tensor to the pack.

[in]tensorTensor to add
[in]slot_idSlot identification in respect to the operator of the tensor to add
Status code

Definition at line 44 of file TensorPack.cpp.

References AclSuccess, ITensorPack::add_tensor(), and ITensorV2::tensor().

45 {
46  _pack.add_tensor(slot_id, tensor->tensor());
47  return AclStatus::AclSuccess;
48 }
Call succeeded, leading to valid state for all involved objects/data.
Definition: AclTypes.h:51
void add_tensor(int id, ITensor *tensor)
Add tensor to the pack.
Definition: ITensorPack.cpp:39

◆ empty()

bool empty ( ) const

Checks if pack is empty.

True if empty else false

Definition at line 55 of file TensorPack.cpp.

References ITensorPack::empty().

56 {
57  return _pack.empty();
58 }
bool empty() const
Checks if pack is empty.
Definition: ITensorPack.cpp:80

◆ get_tensor()

arm_compute::ITensor * get_tensor ( int32_t  slot_id)

Get tensor of a given id from the pac.

[in]slot_idSlot identification of tensor to extract
The pointer to the tensor if exist and is non-const else nullptr

Definition at line 65 of file TensorPack.cpp.

References ITensorPack::get_tensor().

66 {
67  return _pack.get_tensor(slot_id);
68 }
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
Definition: ITensorPack.cpp:64

◆ get_tensor_pack()

arm_compute::ITensorPack & get_tensor_pack ( )

Get legacy tensor pack.

Legacy tensor pack

Definition at line 70 of file TensorPack.cpp.

71 {
72  return _pack;
73 }

◆ is_valid()

bool is_valid ( ) const

Checks if an object is valid.

True if valid else false

Definition at line 60 of file TensorPack.cpp.

References AclTensorPack_::header, arm_compute::detail::TensorPack, and Header::type.

Referenced by arm_compute::detail::validate_internal_pack().

61 {
63 }
arm_compute::detail::Header header
Definition: TensorPack.h:32

◆ size()

size_t size ( ) const

Pack size accessor.

Number of tensors registered to the pack

Definition at line 50 of file TensorPack.cpp.

References ITensorPack::size().

51 {
52  return _pack.size();
53 }
size_t size() const
Pack size accessor.
Definition: ITensorPack.cpp:75

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