Conversation
Differential Revision: D15404911 Differential Version: 82207842
|
So now the Dict behavior is different from List or Tuple (both of which while inheriting from intrusive_ptr_target, are actually Impl's not the reference-like wrappers). They should behave the same. But then there's the question of how they should behave - as regular C++ types (so you'd pass I personally don't like the idea of magical wrappers proliferation as it's non-C++ and is pretty confusing. Tensor is kind of an exception, but in other cases, would it be so bad to explicitly write wrapper? (or we could define explicit DictPtr) |
|
IValue stores Dicts as some kind of Unfortunately, this breaks with IValue because there might be multiple IValues holding a pointer to the same I'm open to alternative ideas. |
|
Thanks for the detailed description, it wasn't clear from the PR description originally! In that case indeed, whatever C++ type we pass into the kernel has to be "reference semantics" in C++. In that case - how about we just rename |
|
|
|
@dzhulgakov proposed to call it |
Differential Revision: D15404911 Differential Version: 82764811
|
changes done. Please re-review. |
Differential Revision: D15404911 Differential Version: 82766851
zdevito
left a comment
There was a problem hiding this comment.
Implementation seems good.
But this will give us at::ArrayRef<...> and c10::DictPtr. What is the distinction between a Ref and a Ptr?
|
@zdevito |
Differential Revision: D15404911 Differential Version: 82786237
Differential Revision: D15404911 Differential Version: 82910251
Differential Revision: D15404911 Differential Version: 82910671
Summary: Pull Request resolved: pytorch/pytorch#20669 Before, Dict was a value type, i.e. copying it did a deep copy. Unfortunately, this doesn't work well with storing and passing Dicts around in IValues because IValues are reference types. This diff changes Dict to be a reference type. Reviewed By: dzhulgakov Differential Revision: D15404911 fbshipit-source-id: dc990d3eb7cae044b74dd0253f8b704dde6a6c86
|
This pull request has been merged in d5b7138. |
Stack:
:white_circle: #20871 Use c10::List 💛
:white_circle: #20870 List 💛
:black_circle: #20669 Dict is a reference type 💚
Before, Dict was a value type, i.e. copying it did a deep copy.
Unfortunately, this doesn't work well with storing and passing Dicts around in IValues because IValues are reference types.
This diff changes Dict to be a reference type.
Differential Revision: D15404911