Compute Library
 22.05
CpuAuxTensorHandler Class Reference

#include <CpuAuxTensorHandler.h>

Public Member Functions

 CpuAuxTensorHandler (int slot_id, TensorInfo &info, ITensorPack &pack, bool pack_inject=false, bool bypass_alloc=false)
 
 CpuAuxTensorHandler (TensorInfo &info, ITensor &tensor)
 
 CpuAuxTensorHandler (const CpuAuxTensorHandler &)=delete
 
CpuAuxTensorHandleroperator= (const CpuAuxTensorHandler)=delete
 
 ~CpuAuxTensorHandler ()
 
ITensorget ()
 
ITensoroperator() ()
 

Detailed Description

Definition at line 39 of file CpuAuxTensorHandler.h.

Constructor & Destructor Documentation

◆ CpuAuxTensorHandler() [1/3]

CpuAuxTensorHandler ( int  slot_id,
TensorInfo info,
ITensorPack pack,
bool  pack_inject = false,
bool  bypass_alloc = false 
)
inline

Definition at line 42 of file CpuAuxTensorHandler.h.

References ITensorPack::add_tensor(), TensorAllocator::allocate(), Tensor::allocator(), ARM_COMPUTE_LOG_INFO_WITH_FUNCNAME_ACL, ITensor::buffer(), ITensorPack::get_tensor(), TensorAllocator::import_memory(), ITensor::info(), arm_compute::test::validation::pack, ITensorAllocator::soft_init(), ITensorInfo::total_size(), and TensorInfo::total_size().

Referenced by CpuAuxTensorHandler::CpuAuxTensorHandler().

43  : _tensor()
44  {
45  if(info.total_size() == 0)
46  {
47  return;
48  }
49  _tensor.allocator()->soft_init(info);
50 
51  ITensor *packed_tensor = utils::cast::polymorphic_downcast<ITensor *>(pack.get_tensor(slot_id));
52  if((packed_tensor == nullptr) || (info.total_size() > packed_tensor->info()->total_size()))
53  {
54  if(!bypass_alloc)
55  {
56  _tensor.allocator()->allocate();
57  ARM_COMPUTE_LOG_INFO_WITH_FUNCNAME_ACL("Allocating auxiliary tensor");
58  }
59 
60  if(pack_inject)
61  {
62  pack.add_tensor(slot_id, &_tensor);
63  _injected_tensor_pack = &pack;
64  _injected_slot_id = slot_id;
65  }
66  }
67  else
68  {
69  _tensor.allocator()->import_memory(packed_tensor->buffer());
70  }
71  }
void soft_init(TensorInfo &input, size_t alignment=0)
Initialize a tensor based with a reference TensorInfo.
#define ARM_COMPUTE_LOG_INFO_WITH_FUNCNAME_ACL(msg)
Log an information message to the logger with function name before the message.
Definition: Log.h:99
TensorAllocator * allocator()
Return a pointer to the tensor&#39;s allocator.
Definition: Tensor.cpp:48
void allocate() override
Allocate size specified by TensorInfo of CPU memory.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
Definition: ITensorPack.cpp:64
Status import_memory(void *memory)
Import an existing memory as a tensor&#39;s backing memory.
void add_tensor(int id, ITensor *tensor)
Add tensor to the pack.
Definition: ITensorPack.cpp:39

◆ CpuAuxTensorHandler() [2/3]

CpuAuxTensorHandler ( TensorInfo info,
ITensor tensor 
)
inline

Definition at line 73 of file CpuAuxTensorHandler.h.

References Tensor::allocator(), ITensor::buffer(), CpuAuxTensorHandler::CpuAuxTensorHandler(), TensorAllocator::import_memory(), ITensor::info(), CpuAuxTensorHandler::operator=(), ITensorAllocator::soft_init(), ITensorInfo::total_size(), and TensorInfo::total_size().

74  : _tensor()
75  {
76  _tensor.allocator()->soft_init(info);
77  if(info.total_size() <= tensor.info()->total_size())
78  {
79  _tensor.allocator()->import_memory(tensor.buffer());
80  }
81  }
void soft_init(TensorInfo &input, size_t alignment=0)
Initialize a tensor based with a reference TensorInfo.
TensorAllocator * allocator()
Return a pointer to the tensor&#39;s allocator.
Definition: Tensor.cpp:48
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Status import_memory(void *memory)
Import an existing memory as a tensor&#39;s backing memory.

◆ CpuAuxTensorHandler() [3/3]

◆ ~CpuAuxTensorHandler()

~CpuAuxTensorHandler ( )
inline

Definition at line 86 of file CpuAuxTensorHandler.h.

References ITensorPack::remove_tensor().

87  {
88  if(_injected_tensor_pack)
89  {
90  _injected_tensor_pack->remove_tensor(_injected_slot_id);
91  }
92  }
void remove_tensor(int id)
Remove the tensor stored with the given id.
Definition: ITensorPack.cpp:70

Member Function Documentation

◆ get()

◆ operator()()

ITensor* operator() ( )
inline

Definition at line 99 of file CpuAuxTensorHandler.h.

References arm_compute::ACL_UNKNOWN.

100  {
101  return &_tensor;
102  }

◆ operator=()


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