Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

non-contiguous copy still buggy #90

Closed
soumith opened this issue Dec 10, 2014 · 4 comments · Fixed by #93
Closed

non-contiguous copy still buggy #90

soumith opened this issue Dec 10, 2014 · 4 comments · Fixed by #93

Comments

@soumith
Copy link
Member

soumith commented Dec 10, 2014

Test case:

require 'cutorch'

val = 1
ps = torch.LongStorage({4, 4, 4})
cube = torch.Tensor(ps):apply(function()
          val = val + 1
          return val
         end):cuda()

ps = torch.LongStorage({4, 12})
x = torch.CudaTensor(ps):fill(-1)

l = 2
h = 1
w = 2

print(cube)
print(cube[l][{{h,h+2},{w,w+2}}])

x[{{1},{1,9}}]:copy(cube[l][{{h,h+2},{w,w+2}}]:contiguous())
print(x)

x[{{1},{1,9}}]:copy(cube[l][{{h,h+2},{w,w+2}}])
print(x)

x[{{1,1},{1,9}}]:copy(cube[l][{{h,h+2},{w,w+2}}])
print(x)


x[{1,{1,9}}]:copy(cube[l][{{h,h+2},{w,w+2}}])
print(x)

Output:

(1,.,.) =
   2   3   4   5
   6   7   8   9
  10  11  12  13
  14  15  16  17

(2,.,.) =
  18  19  20  21
  22  23  24  25
  26  27  28  29
  30  31  32  33

(3,.,.) =
  34  35  36  37
  38  39  40  41
  42  43  44  45
  46  47  48  49

(4,.,.) =
  50  51  52  53
  54  55  56  57
  58  59  60  61
  62  63  64  65
[torch.CudaTensor of dimension 4x4x4]

 19  20  21
 23  24  25
 27  28  29
[torch.CudaTensor of dimension 3x3]

 19  20  21  23  24  25  27  28  29  -1  -1  -1
 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1
 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1
 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1
[torch.CudaTensor of dimension 4x12]

 19  20  21  22  23  24  25  26  27  -1  -1  -1
 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1
 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1
 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1
[torch.CudaTensor of dimension 4x12]

 19  20  21  22  23  24  25  26  27  -1  -1  -1
 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1
 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1
 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1
[torch.CudaTensor of dimension 4x12]

 19  20  21  22  23  24  25  26  27  -1  -1  -1
 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1
 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1
 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1
[torch.CudaTensor of dimension 4x12]
@nicholas-leonard
Copy link
Member

So the last 3 are wrong?

@soumith
Copy link
Member Author

soumith commented Dec 10, 2014

yea 👎

@soumith
Copy link
Member Author

soumith commented Dec 11, 2014

update: one of the engineers at FB is fixing this.

@nicholas-leonard
Copy link
Member

Awesome.

soumith added a commit that referenced this issue Dec 30, 2014
…a robust and completely randomized copy test. Also fixes #90
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 a pull request may close this issue.

2 participants