Skip to content

Conversation

@ptrblck
Copy link
Collaborator

@ptrblck ptrblck commented Aug 10, 2018

No description provided.

@ptrblck
Copy link
Collaborator Author

ptrblck commented Aug 10, 2018

Link to issue: #10402

@ezyang
Copy link
Contributor

ezyang commented Aug 10, 2018

Can we get a test?

@ptrblck
Copy link
Collaborator Author

ptrblck commented Aug 10, 2018

@ezyang Do you mean a specific test in pytorch/test/.. or an executable code snippet?
If the latter:

import torch
import torch.nn as nn

batch_size = 10
channels = 3
h, w = 16, 16
x = torch.randn(batch_size, channels, h, w)

pool = nn.AvgPool2d((1, 2), (1, 2))
output = pool(x)
output = output.view(batch_size, channels, h//2, 2, w//2)
print(output.select(3, 1).mul_(-1))

doesn't throw an error in the last line.

If the former, sure, where should I add it?

ssnl
ssnl previously requested changes Aug 10, 2018
else:
return self
if self.size(0) > 2 * PRINT_OPTS.edgeitems:
self = self.contiguous()

This comment was marked as off-topic.

This comment was marked as off-topic.

@ssnl
Copy link
Collaborator

ssnl commented Aug 10, 2018

@ptrblck For test, you can manually create a tensor and use as_strided to get the special size and strides, and add the test case to TestTorch (probably test_print).

@soumith soumith changed the title fixes #10402 fixes printing non-contiguous tensors Aug 13, 2018
@ptrblck
Copy link
Collaborator Author

ptrblck commented Aug 13, 2018

@ezyang @ssnl I've added a test case and used .reshape(-1) on the printed lines.
Somehow the automatic checks are failing, so I'll have a look for the reason.

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

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.

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

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.

soumith is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

goodlux pushed a commit to goodlux/pytorch that referenced this pull request Aug 15, 2018
Summary: Pull Request resolved: pytorch#10405

Differential Revision: D9302794

Pulled By: soumith

fbshipit-source-id: e4a7db8d33400a5a050d05fd1679de8bc3cbcf30
@ptrblck ptrblck deleted the print_tensor branch August 30, 2018 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants