Compute Library
 23.08
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 }

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 arm_compute::graph::detail::fuse_pad_with_convolution(), and 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 109 of file Tensor.cpp.

110 {
111  _bound_edges.insert(eid);
112 }

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 119 of file Tensor.cpp.

120 {
121  return _bound_edges;
122 }

◆ 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  const bool access_data = _accessor->access_tensor_data();
84 
85  if(access_data)
86  {
87  // Map tensor
88  _handle->map(true);
89 
90  // Return in case of null backend buffer
91  if(_handle->tensor().buffer() == nullptr)
92  {
93  return false;
94  }
95  }
96 
97  // Call accessor
98  bool retval = _accessor->access_tensor(_handle->tensor());
99 
100  if(access_data)
101  {
102  // Unmap tensor
103  _handle->unmap();
104  }
105 
106  return retval;
107 }

◆ desc() [1/2]

◆ desc() [2/2]

const TensorDescriptor& desc ( ) const

TensorInfo metadata accessor.

Returns
Tensor descriptor metadata

◆ 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 }

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

◆ handle()

ITensorHandle * handle ( )

Backend tensor handle accessor.

Returns
Backend tensor handle

Definition at line 55 of file Tensor.cpp.

56 {
57  return _handle.get();
58 }

Referenced by SplitLayerSubTensorMutator::mutate().

◆ 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 }

References Tensor::accessor().

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

◆ 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 SplitLayerSubTensorMutator::mutate().

◆ unbind_edge()

void unbind_edge ( EdgeID  eid)

Unbinds an edge from a tensor.

Parameters
[in]eidEdge to unbind

Definition at line 114 of file Tensor.cpp.

115 {
116  _bound_edges.erase(eid);
117 }

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


The documentation for this class was generated from the following files:
arm_compute::graph::Tensor::accessor
ITensorAccessor * accessor()
Backend tensor accessor.
Definition: Tensor.cpp:65
arm_compute::graph::Tensor::desc
TensorDescriptor & desc()
TensorInfo metadata accessor.
Definition: Tensor.cpp:40