Skip to content

Conversation

@gchanan
Copy link
Contributor

@gchanan gchanan commented Dec 19, 2017

This does the following:

  1. Adds a four-argument CPU apply template
  2. Renames scalar template arguments from "CScalar" to "scalar" as previously agreed.
  3. Uses auto in a bunch of places for the existing apply functions
  4. Added a 'BoolTensor' specification in native_functions to indicate it should be a BoolTensor in Declarations.yaml (this matters for Variable type checking)
  5. Implements 'where' using these above; it's more complex than I would like because you want to figure out the broadcasting backwards implicitly and write the derivative only in terms of same size tensors; this requires writing two different functions (where and _s_where) and writing the derivative in terms of _s_where. I can't currently think of an easier way to do this without adding a bunch of mechanism complexity to the native_functions path.

@pytorchbot
Copy link
Collaborator

@gchanan, thanks for your PR! We identified @zdevito to be a potential reviewer.

Copy link
Member

@colesbury colesbury left a comment

Choose a reason for hiding this comment

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

lgtm

# this allows us to implicitly calculate the broadcast derivative, while only dealing with the
# _s_where derivative.
- func: where(BoolTensor condition, Tensor self, Tensor other) -> Tensor
- func: _s_where(BoolTensor condition, Tensor self, Tensor other) -> Tensor

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

- name: view(Tensor self, IntList size)
self: grad.contiguous().view(self.sizes())

- name: _s_where(Tensor condition, Tensor self, Tensor other)

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

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.

5 participants