-
Notifications
You must be signed in to change notification settings - Fork 159
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] attach extra tensor to tensor builder #13326
Conversation
13d4b96
to
e332c24
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
@nnfw-bot test onert-cross-release |
cb7cca5
to
e191a29
Compare
e7fd283
to
0f65e6d
Compare
// [idea2] : Generate Extra Tensors by traversing code_map | ||
|
||
// Problem 1 : | ||
// Since code_map lost its' backend context, | ||
// it is hard to specify where estra tensor should be registered. | ||
|
||
// Problme 2: | ||
// Since ITrainableFunction is in exec area, it isn't a good idea to use member function of *Layer | ||
// here, Istead of exec area interface, we have to implement another backend interface | ||
|
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.
.
IMO
ex.) CPU backend create tensor and allocate at once in Create tensors ONE/runtime/onert/backend/acl_common/AclBackendContext.h Lines 70 to 85 in dfd595b
Allocation after kernel generation
|
@hseok-oh Thank you a lot for taking a look 😄 I catched your point. It looks quite good 👍 😄 Since I already implemented ExtraTensorManage and ExtraTensorIndex .. etc, I could quickly implement your suggestions. I'll revise it right now. |
0f65e6d
to
fd174ee
Compare
(WIP) This draft try to attach extra tensors to tensor builder. ONE-DCO-1.0-Signed-off-by: SeungHui Youn <[email protected]>
a6ed87c
to
4e9ec7e
Compare
b37741f
to
f7c052d
Compare
{ | ||
assert(_mem_planner->memory_plans().find(ind) != _mem_planner->memory_plans().end()); | ||
const auto &mem_blk = _mem_planner->memory_plans().at(ind); | ||
return _mem_alloc->base() + mem_blk.offset; | ||
} | ||
|
||
// specialization |
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.
It's template instantiation, not specialization. I'm not sure if it's template instantiation.
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.
Anyway, I have a question.
If template member functions are defined in a cc file, can these instantiated template class be used in other cc files without including this cc file?
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.
If template member functions are defined in a cc file, can these instantiated template class be used in other cc files without including this cc file?
Yes, I don't know why. But this worked well.
I'd better check accurate C++ grammar related to this
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'm very surprised that it works. I'm curious about the reason why there is no compilation problem.
However, I'm worried about multiple definition problem if those instantiated template classes are used in multiple cc files. Could you check that too?
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'm worried about multiple definition problem if those instantiated template classes are used in multiple cc files. Could you check that too?
That's why I put instantiation here.
I first tried it in the header, but the compiler complains about multiple definitions.
I'm very surprised that it works. I'm curious about the reason why there is no compilation problem
I couldn't fully understand why it works. But I could find similar answers in stack overflow :
https://stackoverflow.com/questions/32707522/explicit-instantiation-of-template
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 first tried it in the header, but the compiler complains about multiple definitions.
Usually, we have resolved by using inline
keyword. Anyway, it seems that there is no complaint about multiple definition with the template instantiation.
I couldn't fully understand why it works. But I could find similar answers in stack overflow :
https://stackoverflow.com/questions/32707522/explicit-instantiation-of-template
I also found a related answers in https://isocpp.org/wiki/faq/templates#separate-template-fn-defn-from-decl.
(WIP) This draft try to attach extra tensors to tensor builder.
ONE-DCO-1.0-Signed-off-by: SeungHui Youn [email protected]
related : #13282