ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 30 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 56 of file TensorRegistry.h.

57 {
58 return _disposable_back_prop;
59 }

◆ getDisposableBackPropTensor()

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

Definition at line 34 of file TensorRegistry.h.

35 {
36 auto itr = _disposable_back_prop.find(index);
37 if (itr != _disposable_back_prop.end())
38 return itr->second.get();
39
40 return nullptr;
41 }

◆ getLayerScopeTensor()

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

Definition at line 61 of file TensorRegistry.h.

62 {
63 auto itr = _layer_scope.find(index);
64 if (itr != _layer_scope.end())
65 return itr->second;
66
67 return nullptr;
68 }

◆ layerscope_tensors()

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

Definition at line 83 of file TensorRegistry.h.

84 {
85 return _layer_scope;
86 }

◆ setDisposableBackPropTensor()

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

Definition at line 43 of file TensorRegistry.h.

45 {
46 assert(tensor != nullptr);
47 auto itr = _disposable_back_prop.find(index);
48 if (itr != _disposable_back_prop.end())
49 throw std::runtime_error{
50 "Tried to set a disposable tensor but another disposable tensor already exists."};
51
52 _disposable_back_prop[index] = std::move(tensor);
53 }
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 70 of file TensorRegistry.h.

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

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