Skip to content

Conversation

ChunliF
Copy link
Contributor

@ChunliF ChunliF commented Jun 26, 2018

Add BatchTensor class

  • construct from data, mask, dims or construct from list of tensors
  • can return a list of tensors from an BatchTensor class

next step: do IR level transformation and operators

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@ezyang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Collaborator

@jamesr66a jamesr66a left a comment

Choose a reason for hiding this comment

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

Looks fine, I'd just like to see more comments describing what's going on

this->dims = dims;
}

BatchTensor::BatchTensor(std::vector<at::Tensor> datalist, std::vector<bool> dims) {

This comment was marked as off-topic.

This comment was marked as off-topic.

data_item += datalist[i];
mask_item.fill_(1);
}
this->dims = dims;

This comment was marked as off-topic.

}
this->data = data;
this->mask = mask;
this->dims = dims;

This comment was marked as off-topic.

this->dims = dims;
}

std::vector<at::Tensor> BatchTensor::examples() {

This comment was marked as off-topic.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@ezyang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@zdevito zdevito left a comment

Choose a reason for hiding this comment

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

Code looks good except for a few nits. We need some documentation of the storage formula in the header file though, otherwise it is really hard to follow the code.

.def(py::init<at::Tensor, at::Tensor, at::Tensor>())
.def(py::init<std::vector<at::Tensor>, at::Tensor>())
.def("examples", &BatchTensor::examples)
.def("get_data", &BatchTensor::getData)

This comment was marked as off-topic.

test/test_jit.py Outdated
else:
super(TestBatched, self).assertEqual(x, y, prec, message, allow_inf)

def mb_rand(self, *dims):

This comment was marked as off-topic.

test/test_jit.py Outdated


class TestBatched(TestCase):
def assertEqual(self, xs, ybs, prec=None, message='', allow_inf=False):

This comment was marked as off-topic.

}

public:
at::Tensor data;

This comment was marked as off-topic.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@ezyang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ezyang
Copy link
Contributor

ezyang commented Jun 29, 2018

@zdevito Just want to confirm that we agreed that we won't try to make BatchTensor wind it's way through all of the existing machinery?

@zdevito
Copy link
Contributor

zdevito commented Jun 29, 2018

@ezyang -- yes we are going to make it a separate type in python, and represent it as a tuple in the script. In the future when we can define new types more easily we can make it more integrated but it is far to complicated to do it correct right now.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@ChunliF has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ssnl
Copy link
Collaborator

ssnl commented Jul 6, 2018

Sorry to send another email to everyone's inbox. Are we decided that the Python BatchTensor lives in top-level torch. namespace (vs. something like torch.jit.BatchTensor)?

@apaszke
Copy link
Contributor

apaszke commented Jul 6, 2018

@ssnl good point, it most definitely should be hidden.

@ChunliF
Copy link
Contributor Author

ChunliF commented Jul 10, 2018

@ssnl Thanks! Fixed in #9198

@ChunliF ChunliF deleted the batchtensor branch July 12, 2018 01:24
goodlux pushed a commit to goodlux/pytorch that referenced this pull request Aug 15, 2018
Summary:
Add BatchTensor class
- construct from data, mask, dims or construct from list of tensors
- can return a list of tensors from an BatchTensor class

next step: do IR level transformation and operators
Closes pytorch#8922

Differential Revision: D8668986

Pulled By: ChunliF

fbshipit-source-id: 8b24d2a9f46a3b42dbb397e99e9e059dfb2b326e
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.

7 participants