diff options
author | Dominik Grewe <dominik.grewe@gmail.com> | 2015-05-01 18:57:16 +0300 |
---|---|---|
committer | Dominik Grewe <dominik.grewe@gmail.com> | 2015-05-01 18:57:16 +0300 |
commit | 0bcd1360abdd507cd91f49d6ccd7cfe1b663201d (patch) | |
tree | 107ee74d8101c1d678cbc4735ba55b7923b26273 /TensorOperator.c | |
parent | e0722c7765d37bbdb8594ae466088e9dda331659 (diff) | |
parent | d88ac24c712e3a40d4aaf3ac2d043bd79ba4280e (diff) |
Merge pull request #144 from adamlerer/auto_device2
Auto device: API changes, bug fixes, README.md
Diffstat (limited to 'TensorOperator.c')
-rw-r--r-- | TensorOperator.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/TensorOperator.c b/TensorOperator.c index a5dab99..bbd33b5 100644 --- a/TensorOperator.c +++ b/TensorOperator.c @@ -8,6 +8,7 @@ static int cutorch_CudaTensorOperator___add__(lua_State *L) THCudaTensor *tensor2 = luaT_toudata(L, 2, "torch.CudaTensor"); THCudaTensor *r; THCState *state = cutorch_getstate(L); + THAssert(THCudaTensor_checkGPU(state, 2, tensor1, tensor2)); if(!tensor1 && !tensor2) luaL_error(L, "expecting two Tensors or one Tensor and one number"); @@ -44,6 +45,7 @@ static int cutorch_CudaTensorOperator___sub__(lua_State *L) THCudaTensor *tensor2 = luaT_toudata(L, 2, "torch.CudaTensor"); THCudaTensor *r; THCState *state = cutorch_getstate(L); + THAssert(THCudaTensor_checkGPU(state, 2, tensor1, tensor2)); if(!tensor1 && !tensor2) luaL_error(L, "expecting two Tensors or one Tensor and one number"); @@ -79,6 +81,7 @@ static int cutorch_CudaTensorOperator___unm__(lua_State *L) THCudaTensor *tensor = luaT_checkudata(L, 1, "torch.CudaTensor"); THCudaTensor *r; THCState *state = cutorch_getstate(L); + THAssert(THCudaTensor_checkGPU(state, 1, tensor)); r = THCudaTensor_new(state); luaT_pushudata(L, r, "torch.CudaTensor"); @@ -95,6 +98,7 @@ static int cutorch_CudaTensorOperator___mul__(lua_State *L) THCudaTensor *tensor2 = luaT_toudata(L, 2, "torch.CudaTensor"); THCudaTensor *r; THCState *state = cutorch_getstate(L); + THAssert(THCudaTensor_checkGPU(state, 2, tensor1, tensor2)); if(!tensor1 && !tensor2) luaL_error(L, "expecting two Tensors or one Tensor and one number"); @@ -146,6 +150,7 @@ static int cutorch_CudaTensorOperator___div__(lua_State *L) THCudaTensor *tensor = luaT_checkudata(L, 1, "torch.CudaTensor"); THCudaTensor *r; THCState *state = cutorch_getstate(L); + THAssert(THCudaTensor_checkGPU(state, 1, tensor)); luaL_argcheck(L, lua_isnumber(L,2), 2, "number expected"); |