Skip to content

Conversation

@zdevito
Copy link
Contributor

@zdevito zdevito commented Jun 15, 2018

We have 2 use cases where we want to experiment with new base ATen
tensor types:

  • BatchTensor for matchbox
  • Tensors that live on accelerators

It is possible to subclass TensorImpl to implement these but VariableType
does not work with them because it cannot find the equivalent variable type
in the registry.

This commit changes the way we implement type -> variable(type) lookup so that
torch::register_variable_type_for can be called on any at::Type.

Lookups are still done using arrays so there should be no perf impact from the change.

We have 2 use cases where we want to experiment with new base ATen
tensor types:

* BatchTensor for matchbox
* Tensors that live on accelerators

It is possible to subclass TensorImpl to implement these but VariableType
does not work with them because it cannot find the equivalent variable type
in the registry.

This commit changes the way we implement type -> variable(type) lookup so that
torch::register_variable_type_for can be called on any at::Type.

Lookups are still done using arrays so there should be no perf impact from the change.
return "VariableType";
}

// Pre-condition: backend/scalar_type is a valid type in the type_registry

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be some additional legwork to do when binding to Python in PyTypeObject, but the rest looks good.

@zdevito zdevito merged commit d968614 into pytorch:master Jun 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants