ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::backend::train::TensorRegistry Class Reference

#include <TensorRegistry.h>

Collaboration diagram for onert::backend::train::TensorRegistry:

Public Member Functions

BackPropTensorgetDisposableBackPropTensor (const DisposableTensorIndex &index)
 
void setDisposableBackPropTensor (const DisposableTensorIndex &index, std::unique_ptr< BackPropTensor > tensor)
 
const std::unordered_map< DisposableTensorIndex, std::unique_ptr< BackPropTensor > > & disposable_back_prop_tensors ()
 
std::shared_ptr< LayerScopeTensorgetLayerScopeTensor (const LayerScopeTensorIndex &index)
 
void setLayerScopeTensor (const LayerScopeTensorIndex &index, std::shared_ptr< LayerScopeTensor > &tensor)
 
const std::unordered_map< LayerScopeTensorIndex, std::shared_ptr< LayerScopeTensor > > & layerscope_tensors ()
 
- Public Member Functions inherited from onert::backend::train::PortableTensorRegistryTemplate< Tensor, TrainableTensor, BackPropTensor, GradientTensor >
ITensorgetITensor (const ir::OperandIndex &index) override
 Returns pointer of ITensor among native and migrant tensors.
 
ITensorgetNativeITensor (const ir::OperandIndex &index) override
 Returns pointer of ITensor among native tensors.
 
ITensorgetBackPropITensor (const ir::OperandIndex &index) override
 Returns pointer of ITensor for back propatation.
 
ITensorgetGradientITensor (const ir::OperandIndex &index) override
 Returns pointer of ITensor for gradient.
 
void iterateTrainableTensors (const std::function< void(const ir::OperandIndex &, const train::ITrainableTensor *)> &fn) const override
 Iterate ITrainableTensors with fn.
 
IPortableTensorgetPortableTensor (const ir::OperandIndex &index)
 
TensorgetNonConstTensor (const ir::OperandIndex &index)
 
TrainableTensorgetTrainableTensor (const ir::OperandIndex &index)
 
BackPropTensorgetBackPropTensor (const ir::OperandIndex &index)
 
GradientTensorgetGradientTensor (const ir::OperandIndex &index)
 
TrainingTensors getTrainingTensors (const ir::OperandIndex &index)
 
bool setMigrantTensor (const ir::OperandIndex &index, IPortableTensor *tensor) override
 Set the Migrant Tensor which are from other backends.
 
void setNonConstTensor (const ir::OperandIndex &index, std::unique_ptr< Tensor > tensor)
 
void setTrainableTensor (const ir::OperandIndex &index, std::unique_ptr< TrainableTensor > tensor)
 
void setBackPropTensor (const ir::OperandIndex &index, std::unique_ptr< BackPropTensor > tensor)
 
void setGradientTensor (const ir::OperandIndex &index, std::unique_ptr< GradientTensor > tensor)
 
const ir::OperandIndexMap< std::unique_ptr< TrainableTensor > > & trainable_tensors ()
 
const ir::OperandIndexMap< std::unique_ptr< Tensor > > & nonconst_tensors ()
 
const ir::OperandIndexMap< std::unique_ptr< Tensor > > & back_prop_tensors ()
 
const ir::OperandIndexMap< std::unique_ptr< GradientTensor > > & gradient_tensors ()
 
- Public Member Functions inherited from onert::backend::ITensorRegistry
virtual ~ITensorRegistry ()=default
 Deconstruct itself.
 

Additional Inherited Members

- Public Types inherited from onert::backend::train::PortableTensorRegistryTemplate< Tensor, TrainableTensor, BackPropTensor, GradientTensor >
using TrainingTensors = std::tuple< TrainableTensor *, GradientTensor * >
 

Detailed Description

Definition at line 34 of file TensorRegistry.h.

Member Function Documentation

◆ disposable_back_prop_tensors()

const std::unordered_map< DisposableTensorIndex, std::unique_ptr< BackPropTensor > > & onert::backend::train::TensorRegistry::disposable_back_prop_tensors ( )
inline

Definition at line 60 of file TensorRegistry.h.

61 {
62 return _disposable_back_prop;
63 }

◆ getDisposableBackPropTensor()

BackPropTensor * onert::backend::train::TensorRegistry::getDisposableBackPropTensor ( const DisposableTensorIndex index)
inline

Definition at line 38 of file TensorRegistry.h.

39 {
40 auto itr = _disposable_back_prop.find(index);
41 if (itr != _disposable_back_prop.end())
42 return itr->second.get();
43
44 return nullptr;
45 }

◆ getLayerScopeTensor()

std::shared_ptr< LayerScopeTensor > onert::backend::train::TensorRegistry::getLayerScopeTensor ( const LayerScopeTensorIndex index)
inline

Definition at line 65 of file TensorRegistry.h.

66 {
67 auto itr = _layer_scope.find(index);
68 if (itr != _layer_scope.end())
69 return itr->second;
70
71 return nullptr;
72 }

◆ layerscope_tensors()

const std::unordered_map< LayerScopeTensorIndex, std::shared_ptr< LayerScopeTensor > > & onert::backend::train::TensorRegistry::layerscope_tensors ( )
inline

Definition at line 87 of file TensorRegistry.h.

88 {
89 return _layer_scope;
90 }

◆ setDisposableBackPropTensor()

void onert::backend::train::TensorRegistry::setDisposableBackPropTensor ( const DisposableTensorIndex index,
std::unique_ptr< BackPropTensor tensor 
)
inline

Definition at line 47 of file TensorRegistry.h.

49 {
50 assert(tensor != nullptr);
51 auto itr = _disposable_back_prop.find(index);
52 if (itr != _disposable_back_prop.end())
53 throw std::runtime_error{
54 "Tried to set a disposable tensor but another disposable tensor already exists."};
55
56 _disposable_back_prop[index] = std::move(tensor);
57 }
loco::GraphInputIndex index(const TFPlaceholder *node)
Definition TFNode.cpp:54

◆ setLayerScopeTensor()

void onert::backend::train::TensorRegistry::setLayerScopeTensor ( const LayerScopeTensorIndex index,
std::shared_ptr< LayerScopeTensor > &  tensor 
)
inline

Definition at line 74 of file TensorRegistry.h.

76 {
77 assert(tensor != nullptr);
78 auto itr = _layer_scope.find(index);
79 if (itr != _layer_scope.end())
80 throw std::runtime_error{
81 "Tried to set a layer scope tensor but another layer scope tensor already exists."};
82
83 _layer_scope[index] = tensor;
84 }

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