Conversation
Differential Revision: D9578398 Differential Version: 56517363
| // Precondition: Access to this struct is protected by the GIL | ||
| at::Type* aten_type() { | ||
| if (!aten_type_) { | ||
| auto* baseType = globalContext().getTypeOpt(static_cast<at::Backend>(backend), static_cast<at::ScalarType>(scalar_type)); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
|
||
| at::Type& getType(at::ScalarType scalarType, const THPLayout& layout, const at::Device& device) { | ||
| const at::Backend backend = get_backend(device.type() == at::Device::Type::CUDA, layout.layout == at::Layout::Sparse); | ||
| auto baseType = at::globalContext().getTypeOpt(backend, scalarType); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| , sparseDims_(1) | ||
| , denseDims_(0) | ||
| , indices_(globalContext().getTypeOpt(sparseTensorIdToDenseBackend(type_id), ScalarType::Long)->tensor({1, 0})) | ||
| , values_(globalContext().getTypeOpt(sparseTensorIdToDenseBackend(type_id), scalar_type)->tensor()) {} |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
Instead of saying what it's not, is it feasible to say what it is? So, I guess it'd be 'getTensorTypeOpt'? |
|
As with #11077 is it possible to name what it is and not what it not is? |
gchanan
left a comment
There was a problem hiding this comment.
This looks fine, or with Christian's suggestion. Or actually just fully specifying with the is_variable bool or taking TensorOptions seems simpler and we can keep the name when everything is a variable.
|
I don't want to call it 'getTensorTypeOpt' because all 'Variable's are also 'Tensor's, so it's ambiguous. |
|
Re the other comment, I think the idea is that Type is not actually a public facing interface, so it doesn't matter if |
Summary: Pull Request resolved: pytorch/pytorch#11077 getType now supports retrieving variable types, so make it clearer when a getType function does NOT give you a variable type. ``` codemod -d . --extensions cc,cpp,cu,cuh,h getTypeOpt getNonVariableTypeOpt ``` Reviewed By: gchanan Differential Revision: D9578398 fbshipit-source-id: 3ee502ac5c714849917f11ddc71de8eacfdaa9d3
Summary: Pull Request resolved: pytorch#11077 getType now supports retrieving variable types, so make it clearer when a getType function does NOT give you a variable type. ``` codemod -d . --extensions cc,cpp,cu,cuh,h getTypeOpt getNonVariableTypeOpt ``` Reviewed By: gchanan Differential Revision: D9578398 fbshipit-source-id: 3ee502ac5c714849917f11ddc71de8eacfdaa9d3
Rename getTypeOpt to getNonVariableTypeOpt
getType now supports retrieving variable types, so make it clearer
when a getType function does NOT give you a variable type.
Differential Revision: D9578398