diff options
author | Adam Lerer <alerer@fb.com> | 2015-04-04 22:49:40 +0300 |
---|---|---|
committer | Adam Lerer <alerer@fb.com> | 2015-04-30 23:05:46 +0300 |
commit | 4bfd3c0df26606329b77e16e7e2dc11899bb1fec (patch) | |
tree | 8c3f4ca865e2526046f49ffd933138dfe4e7056b /Tensor.lua | |
parent | ee03a0aebd658268d107da943fb68ebdaecb7547 (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.lua | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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 |