ONE - On-device Neural Engine
|
#include <TrainableExecutor.h>
Public Member Functions | |
TrainableExecutor (std::unique_ptr< compiler::train::LoweredTrainableGraph > lowered_graph, backend::train::TrainableBackendContexts &&backend_contexts, const compiler::train::TensorRegistries &tensor_regs, compiler::train::TrainableCodeMap &&code_map, const std::vector< ir::OperationIndex > &forward_order, const std::vector< ir::OperationIndex > &backward_order, const util::TracingCtx *tracing_ctx, const ir::train::LossInfo &training_info) | |
Construct a new TrainableExecutor object. | |
const ir::Graph & | graph () const final |
Returns graph object. | |
void | execute (const std::vector< backend::IPortableTensor * > &inputs, const std::vector< backend::IPortableTensor * > &outputs, const ExecutionOptions &options) override |
Execute with given input/output tensors. | |
uint32_t | inputSize () const override |
Get input size. | |
uint32_t | outputSize () const override |
Get output size. | |
const ir::OperandInfo & | inputInfo (uint32_t index) const override |
Get input info at index. | |
const ir::OperandInfo & | outputInfo (uint32_t index) const override |
Get output info at index. | |
ir::Layout | inputLayout (uint32_t index) const override |
Get input layout at index. | |
ir::Layout | outputLayout (uint32_t index) const override |
Get output layout at index. | |
void | forward (const std::vector< backend::IPortableTensor * > &inputs, const std::vector< backend::IPortableTensor * > &outputs, const ExecutionOptions &options, bool training) |
void | backward (const ExecutionOptions &options, uint32_t training_step) |
void | setIndexedRanks (std::shared_ptr< ir::OperationIndexMap< int64_t > > ranks) final |
Set an ordering on operations. | |
void | addObserver (std::unique_ptr< IExecutionObserver > ref) |
float | getLoss (const ir::IOIndex &pred_io_ind) const |
void | iterateTrainableTensors (const std::function< void(const ir::OperandIndex &, const backend::train::ITrainableTensor *)> &fn) const |
backend::train::TrainableBackendContexts & | getBackendContexts () |
const ExecutionOptions & | currentOptions () const override |
Return current execution configuration. | |
Public Member Functions inherited from onert::exec::IExecutor | |
IExecutor ()=default | |
Construct a new IExecutor object. | |
virtual | ~IExecutor ()=default |
Destroy the IExecutor object. | |
Definition at line 39 of file TrainableExecutor.h.
onert::exec::train::TrainableExecutor::TrainableExecutor | ( | std::unique_ptr< compiler::train::LoweredTrainableGraph > | lowered_graph, |
backend::train::TrainableBackendContexts && | backend_contexts, | ||
const compiler::train::TensorRegistries & | tensor_regs, | ||
compiler::train::TrainableCodeMap && | code_map, | ||
const std::vector< ir::OperationIndex > & | forward_order, | ||
const std::vector< ir::OperationIndex > & | backward_order, | ||
const util::TracingCtx * | tracing_ctx, | ||
const ir::train::LossInfo & | training_info | ||
) |
Construct a new TrainableExecutor object.
lowered_graph | LoweredTrainableGraph object |
tensor_builders | Tensor builders that are currently used |
code_map | ir::Operation and its code map |
Definition at line 31 of file TrainableExecutor.cc.
References onert::ir::train::TrainableGraph::getInputs(), onert::compiler::train::TensorRegistries::getITensor(), and onert::ir::train::TrainableGraph::getOutputs().
|
inline |
Definition at line 98 of file TrainableExecutor.h.
References onert::exec::ExecObservers::add().
void onert::exec::train::TrainableExecutor::backward | ( | const ExecutionOptions & | options, |
uint32_t | training_step | ||
) |
Definition at line 137 of file TrainableExecutor.cc.
Referenced by onert::exec::train::TrainableExecutors::train().
|
inlineoverridevirtual |
Return current execution configuration.
Implements onert::exec::IExecutor.
Definition at line 108 of file TrainableExecutor.h.
|
inlineoverridevirtual |
Execute with given input/output tensors.
Input and output tensors must be given.
[in] | inputs | Tensors that are passed as inputs |
[in] | outputs | Tensors that are passed as outputs |
[in] | options | Execution options |
Implements onert::exec::IExecutor.
Definition at line 59 of file TrainableExecutor.h.
References forward().
void onert::exec::train::TrainableExecutor::forward | ( | const std::vector< backend::IPortableTensor * > & | inputs, |
const std::vector< backend::IPortableTensor * > & | outputs, | ||
const ExecutionOptions & | options, | ||
bool | training | ||
) |
Definition at line 59 of file TrainableExecutor.cc.
Referenced by execute().
|
inline |
Definition at line 106 of file TrainableExecutor.h.
float onert::exec::train::TrainableExecutor::getLoss | ( | const ir::IOIndex & | pred_io_ind | ) | const |
Definition at line 198 of file TrainableExecutor.cc.
References onert::compiler::train::TensorRegistries::getITensor(), onert::ir::train::TrainableGraph::getLossIndex(), onert::ir::train::LossInfo::reduction_type, and onert::ir::train::SumOverBatchSize.
Referenced by onert::exec::train::TrainableExecutors::getLoss().
|
inlinefinalvirtual |
Returns graph object.
Implements onert::exec::IExecutor.
Definition at line 57 of file TrainableExecutor.h.
References onert::ir::train::TrainableGraph::graph().
Referenced by TopologicalSortHelper.TopologicalSortHelper::add_edge(), and TopologicalSortHelper.TopologicalSortHelper::sort_util().
|
inlineoverridevirtual |
Get input info at index.
[in] | index | Index of input |
Implements onert::exec::IExecutor.
Definition at line 70 of file TrainableExecutor.h.
Referenced by onert::exec::train::TrainableExecutors::inputInfo().
|
inlineoverridevirtual |
Get input layout at index.
[in] | index | Index of input |
Implements onert::exec::IExecutor.
Definition at line 80 of file TrainableExecutor.h.
|
inlineoverridevirtual |
Get input size.
Implements onert::exec::IExecutor.
Definition at line 66 of file TrainableExecutor.h.
Referenced by onert::exec::train::TrainableExecutors::inputSize().
void onert::exec::train::TrainableExecutor::iterateTrainableTensors | ( | const std::function< void(const ir::OperandIndex &, const backend::train::ITrainableTensor *)> & | fn | ) | const |
Definition at line 216 of file TrainableExecutor.cc.
References onert::compiler::train::TensorRegistries::iterateTrainableTensors().
Referenced by onert::exec::train::TrainableExecutors::iterateTrainableTensors().
|
inlineoverridevirtual |
Get output info at index.
[in] | index | Index of output |
Implements onert::exec::IExecutor.
Definition at line 75 of file TrainableExecutor.h.
Referenced by onert::exec::train::TrainableExecutors::outputInfo().
|
inlineoverridevirtual |
Get output layout at index.
[in] | index | Index of output |
Implements onert::exec::IExecutor.
Definition at line 82 of file TrainableExecutor.h.
|
inlineoverridevirtual |
Get output size.
Implements onert::exec::IExecutor.
Definition at line 68 of file TrainableExecutor.h.
Referenced by onert::exec::train::TrainableExecutors::outputSize().
|
inlinefinalvirtual |
Set an ordering on operations.
[in] | ranks | The table encoding the ordering |
Implements onert::exec::IExecutor.
Definition at line 93 of file TrainableExecutor.h.