-
Notifications
You must be signed in to change notification settings - Fork 157
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
Draft : Add infra to generate extra tensor #13486
base: master
Are you sure you want to change the base?
Conversation
ae4c45b
to
dde2bbf
Compare
@nnfw-bot test onert-x64-release |
android build fail
|
5ca9a7c
to
80c73f7
Compare
namespace train | ||
{ | ||
|
||
class ExtraTensorGenerator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this class necessary?
_idx_to_request
can moved toTrainableGraph
plan()
can be moved toTensorPlanner
allocate()
is just a single line function
// Implement this if extra tensor is needed | ||
virtual backend::train::ExtraTensorRequests requestExtraTensors() | ||
{ | ||
backend::train::ExtraTensorRequests r; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Q) Why should this object be created in every TrainableFunction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, It isn't.
Only (Pool, Conv, DConv, FC, BinaryArithmetic) Layer requires ExtraTensors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put more comments here: https://github.com/Samsung/ONE/pull/13486/files#r1706502494
Is there a better way - not to create the object every time?
fn_seq->iterate([&](exec::train::ITrainableFunction &fn) { | ||
extra_tensor_gen.register_tensors(op_idx, (&fn)->requestExtraTensors()); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, ExtraTensorRequests
are accessed through ITrainableFunction
without downcasting to the specific layer. So, I'd like to define the interface function(?) in ITrainbleFunction
.
6518364
to
b3afcb1
Compare
This PR adds registerLayerScopeTensors to ITrainableFunction. 'registerLayerScopeTensors` is to register LayerScopeTensor into TensorReigstry. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> draft : Samsung#13486 for : Samsung#13282
This PR adds registerLayerScopeTensors to ITrainableFunction. 'registerLayerScopeTensors` is to register LayerScopeTensor into TensorReigstry. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> draft : Samsung#13486 for : Samsung#13282
std::optional<ExtraTensors> BinaryArithmeticLayer::registerExtraTensors() | ||
{ | ||
ExtraTensors tensors; | ||
|
||
if (_act_back_prop_output != nullptr) | ||
{ | ||
tensors.push_back(_act_back_prop_output); | ||
} | ||
|
||
return std::optional<ExtraTensors>(tensors); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
example of registerLayerScopeTensors
usage
This PR introduces LayerScopeMemoryManager. This Manager will be added to TensorManager and used to allocate LayerScopeTensors. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> draft : Samsung#13486 for : Samsung#13282
This PR introduces LayerScopeMemoryManager. This Manager will be added to TensorManager and used to allocate LayerScopeTensors. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> draft : Samsung#13486 for : Samsung#13282
This PR introduces LayerScopeMemoryManager. This Manager will be added to TensorManager and used to allocate LayerScopeTensors. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> draft : Samsung#13486 for : Samsung#13282
This PR adds LayerScopeTensors into TensorRegistry. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> draft : Samsung#13486 for : Samsung#13282
This PR adds LayerScopeManager into TensorManager. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> draft : Samsung#13486 for : Samsung#13282
This PR adds LayerScopeTensors into TensorRegistry. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> draft : Samsung#13486 for : Samsung#13282
This PR adds LayerScopeTensors into TensorRegistry. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> draft : Samsung#13486 for : Samsung#13282
This PR adds LayerScopeManager into TensorManager. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> draft : Samsung#13486 for : Samsung#13282
b3afcb1
to
82f949c
Compare
82f949c
to
1f26bc4
Compare
// forwading order | ||
const auto f_order = _tgraph.topolSortOperations(); | ||
for (const auto &op_index : f_order) | ||
{ | ||
if (not tensor_builder->isRegisteredLayerScopeTensor(op_index)) | ||
continue; | ||
|
||
auto indices = tensor_builder->getRegisteredLayerScopeTensorIndex(op_index); | ||
for (const auto &idx : indices) | ||
{ | ||
const auto lt = tensor_builder->getLayerScopeTensorLifeTime(idx); | ||
if (lt == LayerScopeTensorLifeTime::FORWARD_TO_BACKWARD) | ||
tensor_builder->notifyLayerScopeFirstUse(idx); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For planning, TensorBuilder
has to provide
LayerScopeTensorIndex
- matched by eachOprationIndex
- LifeTime information of each
LayerScopeTensor
.
This PR adds TensorPlanner::planLayerScopeTensors() and its caller part in BackendContext. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> -------------------------------------- draft : Samsung#13486
This PR adds TensorPlanner::planLayerScopeTensors() and its caller part in BackendContext. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> -------------------------------------- draft : Samsung#13486
This PR adds TensorPlanner::planLayerScopeTensors() and its caller part in BackendContext. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> -------------------------------------- draft : Samsung#13486
This PR registers LayerScopeTensor from each layer into tensor registry. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> -------------------------------------- draft : Samsung#13486
This PR registers LayerScopeTensor from each layer into tensor registry. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> -------------------------------------- draft : Samsung#13486
This PR registers LayerScopeTensor from each layer into tensor registry. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> -------------------------------------- draft : Samsung#13486
This PR registers LayerScopeTensor from each layer into tensor registry. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> -------------------------------------- draft : Samsung#13486
This PR registers LayerScopeTensor from each layer into tensor registry. ONE-DCO-1.0-Signed-off-by: seunghui youn <sseung.youn@samsung.com> -------------------------------------- draft : #13486
I moved the old draft(https://github.com/Samsung/ONE/pull/13326/files#diff-f4aa0ebe5af90acde526ab63faaa7352df19cfbfef06379f2dbeb8da5a5dab86) to new PR.
Because My old code and modifications are mixed up and I feel hard to debug.