nntrainer icon indicating copy to clipboard operation
nntrainer copied to clipboard

Circling back to nomenclature of tensor sharing policy

Open zhoonit opened this issue 3 years ago • 3 comments

Discussion continuing about the nomenclature about policies of tensor sharing before working further.

I have a new idea coming along the discussion There are three level of guarantees a layer is making (analogical to https://en.wikipedia.org/wiki/Exception_safety), just like noexcept specifier, user setting a policy to tensor spec means user is guaranteeing a data integrity to some extent so that the memory utilization can be enhanced.

  1. Identity integrity guarantee = identity will be exactly same as identity is shared
  2. Data integrity guarantee = underlying data won't be changed
  3. Space integrity guarantee = underlying space can be reused explictly
policy A1(=unmanaged) A2 B C D
Identity(meta-data) integrity guarantee x x o x x
Data Integrity guarantee x x o o x
Space integrity guarantee x x o o o
--------------------------- - - - - -
option 1 (current) placeholder unique shared read_only_view maybe_modifying_view
option 2 - new link view shared
option 3 placeholder unique shared view try_reuse

zhoonit avatar Nov 24 '21 06:11 zhoonit

:octocat: cibot: Thank you for posting issue #1736. The person in charge will reply soon.

taos-ci avatar Nov 24 '21 06:11 taos-ci

opinion about option 2: Policy B is direct interpretation of createOrExtend(), i think the term link lacks of the create sections.

Advocates about unique / shared (at option 1, 3): this will be analogical to unique_ptr,shared_ptr, which this tensor will have pretty similar ownership semantics.

zhoonit avatar Nov 24 '21 06:11 zhoonit

shared_ptr allows wrapping a small section of the underlying data, which is representing the case D. In case B, as far as I understand, as the tensor metadata has to remain same, the size must also be same.

Regarding link assumes that case B requires the two tensors remain exactly identical (like symlink). createOrExtend() is a wrapper which will resolve go to case A or case B.

kparichay avatar Nov 25 '21 08:11 kparichay