Compute Library
 21.05
Tensor Class Referencefinal

Tensor object. More...

#include <Tensor.h>

Public Member Functions

 Tensor (TensorID id, TensorDescriptor desc)
 Default constructor. More...
 
TensorID id () const
 Tensor ID accessor. More...
 
TensorDescriptordesc ()
 TensorInfo metadata accessor. More...
 
const TensorDescriptordesc () const
 TensorInfo metadata accessor. More...
 
void set_handle (std::unique_ptr< ITensorHandle > backend_tensor)
 Sets the backend tensor. More...
 
ITensorHandlehandle ()
 Backend tensor handle accessor. More...
 
void set_accessor (std::unique_ptr< ITensorAccessor > accessor)
 Sets the backend tensor accessor. More...
 
ITensorAccessoraccessor ()
 Backend tensor accessor. More...
 
std::unique_ptr< ITensorAccessorextract_accessor ()
 Extracts accessor from the tensor. More...
 
bool call_accessor ()
 Calls accessor on tensor. More...
 
void bind_edge (EdgeID eid)
 Binds the tensor with an edge. More...
 
void unbind_edge (EdgeID eid)
 Unbinds an edge from a tensor. More...
 
std::set< EdgeIDbound_edges () const
 Accessor the edges that are bound with the tensor. More...
 

Detailed Description

Tensor object.

Definition at line 41 of file Tensor.h.

Constructor & Destructor Documentation

◆ Tensor()

Tensor ( TensorID  id,
TensorDescriptor  desc 
)

Default constructor.

Parameters
[in]idTensor ID
[in]descTensor information

Definition at line 30 of file Tensor.cpp.

31  : _id(id), _desc(std::move(desc)), _handle(nullptr), _accessor(nullptr), _bound_edges()
32 {
33 }
TensorDescriptor & desc()
TensorInfo metadata accessor.
Definition: Tensor.cpp:40

Member Function Documentation

◆ accessor()

ITensorAccessor * accessor ( )

Backend tensor accessor.

Returns
Backend tensor accessor

Definition at line 65 of file Tensor.cpp.

66 {
67  return _accessor.get();
68 }

Referenced by Tensor::set_accessor().

◆ bind_edge()

void bind_edge ( EdgeID  eid)

Binds the tensor with an edge.

Parameters
[in]eidEdge ID that is bound to the tensor

Definition at line 101 of file Tensor.cpp.

102 {
103  _bound_edges.insert(eid);
104 }

Referenced by Graph::add_connection(), and INode::set_output_tensor().

◆ bound_edges()

std::set< EdgeID > bound_edges ( ) const

Accessor the edges that are bound with the tensor.

Returns
Bound edges

Definition at line 111 of file Tensor.cpp.

112 {
113  return _bound_edges;
114 }

Referenced by arm_compute::graph::detail::allocate_all_input_tensors(), and arm_compute::graph::detail::allocate_all_output_tensors().

◆ call_accessor()

bool call_accessor ( )

Calls accessor on tensor.

Returns
True if the accessor was called else false

Definition at line 75 of file Tensor.cpp.

76 {
77  // Early exit guard
78  if(!_accessor || !_handle)
79  {
80  return false;
81  }
82 
83  // Map tensor
84  _handle->map(true);
85 
86  // Return in case of null backend buffer
87  if(_handle->tensor().buffer() == nullptr)
88  {
89  return false;
90  }
91 
92  // Call accessor
93  bool retval = _accessor->access_tensor(_handle->tensor());
94 
95  // Unmap tensor
96  _handle->unmap();
97 
98  return retval;
99 }

Referenced by arm_compute::graph::detail::call_tensor_accessor().

◆ desc() [1/2]

◆ desc() [2/2]

const TensorDescriptor & desc ( ) const

TensorInfo metadata accessor.

Returns
Tensor descriptor metadata

Definition at line 45 of file Tensor.cpp.

46 {
47  return _desc;
48 }

◆ extract_accessor()

std::unique_ptr< ITensorAccessor > extract_accessor ( )

Extracts accessor from the tensor.

Warning
Accessor gets unbound from the tensor
Returns
The accessor of the tensor

Definition at line 70 of file Tensor.cpp.

71 {
72  return std::move(_accessor);
73 }

◆ handle()

◆ id()

TensorID id ( ) const

Tensor ID accessor.

Returns
Tensor ID

Definition at line 35 of file Tensor.cpp.

36 {
37  return _id;
38 }

Referenced by Edge::tensor_id().

◆ set_accessor()

void set_accessor ( std::unique_ptr< ITensorAccessor accessor)

Sets the backend tensor accessor.

Parameters
[in]accessorAccessor to set

Definition at line 60 of file Tensor.cpp.

61 {
62  _accessor = std::move(accessor);
63 }
ITensorAccessor * accessor()
Backend tensor accessor.
Definition: Tensor.cpp:65

References Tensor::accessor().

Referenced by GroupedConvolutionMutator::mutate(), and arm_compute::graph::set_tensor_accessor().

◆ set_handle()

void set_handle ( std::unique_ptr< ITensorHandle backend_tensor)

Sets the backend tensor.

Parameters
[in]backend_tensorBackend tensor to set

Definition at line 50 of file Tensor.cpp.

51 {
52  _handle = std::move(backend_tensor);
53 }

Referenced by arm_compute::graph::configure_tensor(), and SplitLayerSubTensorMutator::mutate().

◆ unbind_edge()

void unbind_edge ( EdgeID  eid)

Unbinds an edge from a tensor.

Parameters
[in]eidEdge to unbind

Definition at line 106 of file Tensor.cpp.

107 {
108  _bound_edges.erase(eid);
109 }

Referenced by Graph::remove_connection(), and INode::set_output_tensor().


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