Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[onert] Unify interface for generating tensors #13631

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions runtime/onert/backend/train/BackendContext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,9 @@ getDisposableBackPropTensorList(const ir::train::TrainableGraph &tgraph,
backend::ITensorRegistry *BackendContext::genTensors()
{
planForwardTensors();

_tensor_builder->allocate();

return _tensor_registry.get();
}

backend::train::ITensorRegistry *BackendContext::genTrainingTensors()
{
planBackwardTensors();

_tensor_builder->allocate();
_tensor_builder->allocateBackward();

return _tensor_registry.get();
Expand Down
1 change: 0 additions & 1 deletion runtime/onert/backend/train/BackendContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class BackendContext : public onert::backend::train::TrainableBackendContext

public:
backend::ITensorRegistry *genTensors() override;
backend::train::ITensorRegistry *genTrainingTensors() override;

private:
void planForwardTensors();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class TrainableBackendContext

std::shared_ptr<ITensorRegistry> tensor_registry() { return _tensor_registry; }

virtual ITensorRegistry *genTrainingTensors() = 0;
virtual backend::ITensorRegistry *genTensors() = 0;
virtual FunctionMap genKernels() = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,13 @@ namespace train

backend::ITensorRegistry *BackendContext::genTensors()
{
// For now, there is no need to generate tensors for forwarding.
// For now, there is no need to generate tensors for forwarding and backwarding.
// builtin train backend handles 3 operators: `Permute`, `IF`, `WHILE`.
// `Permute`: Tensor generation is not required.
// `IF`, `WHILE`: Not supported yet
return tensor_registry().get();
}

backend::train::ITensorRegistry *BackendContext::genTrainingTensors()
{
// For now, there is no need to generate tensors for backwarding.
return tensor_registry().get();
}

backend::train::FunctionMap BackendContext::genKernels()
{
backend::train::FunctionMap ret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class BackendContext : public backend::train::TrainableBackendContext
}

backend::ITensorRegistry *genTensors() override;
backend::train::ITensorRegistry *genTrainingTensors() override;

public:
backend::train::FunctionMap genKernels() override;
Expand Down
6 changes: 0 additions & 6 deletions runtime/onert/core/src/compiler/ExecutorFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -746,12 +746,6 @@ exec::IExecutor *ExecutorFactory::createTrainableExecutor(
pair.second->genTensors();
}

for (auto &&pair : tbackend_contexts)
{
auto tctx = pair.second.get();
tctx->genTrainingTensors();
}

prepareMigrantTensors(*lowered_graph, tbackend_contexts);

// Give some runtime objects to builtin KernelGenerator
Expand Down