diff options
author | Greg Heinrich <gheinrich@nvidia.com> | 2016-03-25 17:14:13 +0300 |
---|---|---|
committer | Greg Heinrich <gheinrich@nvidia.com> | 2016-03-25 23:00:24 +0300 |
commit | 02bc67c446d0c42b7831a83ba15bff9677a372d2 (patch) | |
tree | 64d91f02d33f955526e05a05815949826e53f72c /test | |
parent | 7e74cb7464106114b468289f5dcc59744b2d25cd (diff) |
Fix TemporalConvolution output size
Issue seen in updateOutput() when batch size is decreasing (e.g. 256->128):
```
.../torch/install/share/lua/5.1/torch/Tensor.lua:462: Wrong size for view. Input size: 66060288. Output size: 128x256x1008x1
stack traceback:
[C]: in function 'error'
.../torch/install/share/lua/5.1/torch/Tensor.lua:462: in function 'view'
...orch/install/share/lua/5.1/cudnn/TemporalConvolution.lua:62: in function <...orch/install/share/lua/5.1/cudnn/TemporalConvolution.lua:54>
```
See new test cudnntest.TemporalConvolution_reduceBatchSize() for a repro.
Calling a tensor's set() method without extra parameters but the requested storage causes the tensor to see a 1-D view of the full storage (not the associated tensor). For example:
```
th> x=torch.Tensor(10)
[0.0001s]
th> y=x:resize(5)
[0.0001s]
th> torch.Tensor():set(y:storage()):size()
10
[torch.LongStorage of size 1]
[0.0002s]
```
Proposed fix is to specify the desired view through the optional parameters of the set() method.
Diffstat (limited to 'test')
-rw-r--r-- | test/test.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/test.lua b/test/test.lua index 55171c7..fd7693a 100644 --- a/test/test.lua +++ b/test/test.lua @@ -448,6 +448,29 @@ function cudnntest.TemporalConvolution_single() mytester:assertlt(berror:abs():max(), precision_backward, 'error on bias (backward) ') end +function cudnntest.TemporalConvolution_reduceBatchSize() + local inputFrameSize = math.random(1,64) + local outputFrameSize = math.random(1,64) + local ki = math.random(1,15) + local si = math.random(1,ki) + local outi = math.random(1,15) + local ini = (outi-1)*si+ki + local batchSize = 128 + local smallerBatchSize = batchSize/2 + + local input + input = torch.randn(batchSize,ini,inputFrameSize):cuda() + local conv = cudnn.TemporalConvolution(inputFrameSize,outputFrameSize,ki,si):cuda() + local o1 = conv:updateOutput(input) + mytester:asserteq(o1:size(1), batchSize, 'batch size didn\'t match') + + input = torch.randn(smallerBatchSize,ini,inputFrameSize):cuda() + local o2 = conv:updateOutput(input) + mytester:asserteq(o2:size(1), smallerBatchSize, 'batch size didn\'t match') + -- do this again to check it doesn't crash + local o2 = conv:updateOutput(input) + mytester:asserteq(o2:size(1), smallerBatchSize, 'batch size didn\'t match') +end function cudnntest.VolumetricConvolution_forward_single() |