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

Data Structures

class  TrainableTensor
 

Functions

template<typename TensorBuilder >
ITensorRegistrygenTensors (backend::train::TrainableBackendContext &ctx, const std::shared_ptr< TensorBuilder > &tensor_builder)
 

Function Documentation

◆ genTensors()

template<typename TensorBuilder >
ITensorRegistry * onert::backend::basic::train::genTensors ( backend::train::TrainableBackendContext ctx,
const std::shared_ptr< TensorBuilder > &  tensor_builder 
)

Definition at line 34 of file TrainableBackendContextHelpers.h.

36{
37 const auto &tgraph = *ctx.trainable_graph();
38
39 tgraph.operands().iterate([&](const ir::OperandIndex &ind, const ir::Operand &obj) {
40 if (ctx.external_operands().contains(ind))
41 return;
42 tensor_builder->registerTensorInfo(ind, obj.info());
43 });
44
45 // For the executors that does not have fixed linear execution order:
46 // To make tensors never be deallocated, this is a workaround to use static memory planner
47 tgraph.operands().iterate([&](const ir::OperandIndex &ind, const ir::Operand &) {
48 if (tensor_builder->isRegistered(ind))
49 tensor_builder->notifyFirstUse(ind);
50 });
51
52 tensor_builder->allocate();
53
54 return ctx.tensor_registry().get();
55}
std::shared_ptr< ITensorRegistry > tensor_registry()
const ir::train::TrainableGraph * trainable_graph() const
const util::Set< ir::OperandIndex > & external_operands() const
const Operands & operands() const override
void iterate(const std::function< void(const Index &, const Object &)> &fn) const
Iterate over the container with given function.

References onert::backend::train::TrainableBackendContext::external_operands(), onert::util::ObjectManager< Index, Object >::iterate(), onert::ir::train::TrainableGraph::operands(), onert::backend::train::TrainableBackendContext::tensor_registry(), and onert::backend::train::TrainableBackendContext::trainable_graph().