Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/torch7.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Lerer <alerer@fb.com>2015-04-04 22:49:40 +0300
committerAdam Lerer <alerer@fb.com>2015-04-30 23:05:46 +0300
commit4bfd3c0df26606329b77e16e7e2dc11899bb1fec (patch)
tree8c3f4ca865e2526046f49ffd933138dfe4e7056b /Tensor.lua
parentee03a0aebd658268d107da943fb68ebdaecb7547 (diff)
Error message improvements.
* Add C file/line to THError and THArgCheck. Add tensor sizeStr() method. * Add THAssert THAssertMsg functions. * Add sizeDesc() and desc() functions, which return tensor descriptor strings for use in error messages. To avoid memory leaks, we have to pass these strings on the stack within structs, so it's a bit unwieldly. * Improved a bunch of error messages. e.g. ``` th> torch.mm(torch.Tensor(4,4), torch.Tensor(5,5)) size mismatch, m1: [4 x 4], m2: [5 x 5] at /home/alerer/git/torch7-2/lib/TH/generic/THTensorMath.c:511 stack traceback: ... th> torch.Tensor(1):size(4) [...]:1: bad argument #1 to 'size' (dimension 4 out of range of 1D tensor at /home/alerer/git/torch7-2/generic/Tensor.c:16) stack traceback: ... ```
Diffstat (limited to 'Tensor.lua')
-rw-r--r--Tensor.lua3
1 files changed, 3 insertions, 0 deletions
diff --git a/Tensor.lua b/Tensor.lua
index 691b996..fded57e 100644
--- a/Tensor.lua
+++ b/Tensor.lua
@@ -9,6 +9,9 @@ local types = {'Byte', 'Char', 'Short', 'Int', 'Long', 'Float', 'Double'}
-- tostring() functions for Tensor and Storage
local function Storage__printformat(self)
+ if self:size() == 0 then
+ return "", nil, 0
+ end
local intMode = true
local type = torch.typename(self)
-- if type == 'torch.FloatStorage' or type == 'torch.DoubleStorage' then