From d30ab5a0f6871e8efc27f9cd833241ac32363dd7 Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Mon, 4 May 2015 18:53:50 -0400 Subject: Rename unpack to table.unpack for Lua 5.2 Torch7 defines table.unpack to unpack if it is not defined. --- test.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test.lua') diff --git a/test.lua b/test.lua index a28674a..2f7857b 100644 --- a/test.lua +++ b/test.lua @@ -2863,7 +2863,7 @@ function nntest.View() local target = template:size():totable() local module = nn.View(template:size()) mytester:assertTableEq(module:forward(input):size():totable(), target, "Error in forward (1)") - local module = nn.View(unpack(target)) + local module = nn.View(table.unpack(target)) mytester:assertTableEq(module:forward(input):size():totable(), target, "Error in forward (2)") -- Minibatch @@ -2919,7 +2919,7 @@ function nntest.Reshape() local target = template:size():totable() local module = nn.Reshape(template:size()) mytester:assertTableEq(module:forward(input):size():totable(), target, "Error in forward (1)") - local module = nn.View(unpack(target)) + local module = nn.View(table.unpack(target)) mytester:assertTableEq(module:forward(input):size():totable(), target, "Error in forward (2)") -- Minibatch @@ -2945,7 +2945,7 @@ function nntest.SpatialUpSamplingNearest() end -- Check that the gradient is correct by using finite elements - local input = torch.Tensor(unpack(shape)):zero() + local input = torch.Tensor(table.unpack(shape)):zero() local err = jac.testJacobian(m, input) mytester:assertlt(err, precision, ' error on state ') @@ -3190,7 +3190,7 @@ function nntest.MM() local gradOutput = torch.randn(M, P) local gradInput = mm:backward({A, B}, gradOutput) mytester:assert(#gradInput == 2, 'gradInput must be table of size 2') - local gradA, gradB = unpack(gradInput) + local gradA, gradB = table.unpack(gradInput) mytester:assertTableEq(gradA:size():totable(), A:size():totable(), 'Gradient for input A has wrong size') mytester:assertTableEq(gradB:size():totable(), B:size():totable(), @@ -3221,7 +3221,7 @@ function nntest.BatchMMNoTranspose() local gradOutput = torch.randn(bSize, M, P) local gradInput = mm:backward({A, B}, gradOutput) mytester:assert(#gradInput == 2, 'gradInput must be table of size 2') - local gradA, gradB = unpack(gradInput) + local gradA, gradB = table.unpack(gradInput) mytester:assertTableEq(gradA:size():totable(), A:size():totable(), 'Gradient for input A has wrong size') mytester:assertTableEq(gradB:size():totable(), B:size():totable(), @@ -3255,7 +3255,7 @@ function nntest.BatchMMTransposeA() local gradOutput = torch.randn(bSize, M, P) local gradInput = mm:backward({A, B}, gradOutput) mytester:assert(#gradInput == 2, 'gradInput must be table of size 2') - local gradA, gradB = unpack(gradInput) + local gradA, gradB = table.unpack(gradInput) mytester:assertTableEq(gradA:size():totable(), A:size():totable(), 'Gradient for input A has wrong size') mytester:assertTableEq(gradB:size():totable(), B:size():totable(), @@ -3289,7 +3289,7 @@ function nntest.BatchMMTransposeB() local gradOutput = torch.randn(bSize, M, P) local gradInput = mm:backward({A, B}, gradOutput) mytester:assert(#gradInput == 2, 'gradInput must be table of size 2') - local gradA, gradB = unpack(gradInput) + local gradA, gradB = table.unpack(gradInput) mytester:assertTableEq(gradA:size():totable(), A:size():totable(), 'Gradient for input A has wrong size') mytester:assertTableEq(gradB:size():totable(), B:size():totable(), @@ -3323,7 +3323,7 @@ function nntest.BatchMMTransposeBoth() local gradOutput = torch.randn(bSize, M, P) local gradInput = mm:backward({A, B}, gradOutput) mytester:assert(#gradInput == 2, 'gradInput must be table of size 2') - local gradA, gradB = unpack(gradInput) + local gradA, gradB = table.unpack(gradInput) mytester:assertTableEq(gradA:size():totable(), A:size():totable(), 'Gradient for input A has wrong size') mytester:assertTableEq(gradB:size():totable(), B:size():totable(), -- cgit v1.2.3