This repository has been archived by the owner on Aug 3, 2021. It is now read-only.
forked from torch/cutorch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into spec_refactor
Conflicts: CMakeLists.txt Tensor.lua generic/CStorage.c generic/CTensor.c init.c lib/THC/THCCachingAllocator.cpp lib/THC/THCGeneral.c lib/THC/THCGenerateHalfType.h lib/THC/THCHalf.cu lib/THC/THCStorageCopy.c lib/THC/THCStorageCopy.cu lib/THC/THCTensorCopy.c lib/THC/generic/THCStorageCopy.c lib/THC/generic/THCStorageCopy.cu lib/THC/generic/THCStorageCopy.h lib/THC/generic/THCTensorCopy.h test/test_shutdown.lua
- Loading branch information
Showing
65 changed files
with
2,097 additions
and
803 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#ifndef THC_GENERIC_FILE | ||
#define THC_GENERIC_FILE "generic/CStorageCopy.c" | ||
#else | ||
|
||
#include "THHalf.h" | ||
|
||
static int TH_CONCAT_3(cutorch_,Real,Storage_copy)(lua_State *L) | ||
{ | ||
THStorage *storage = luaT_checkudata(L, 1, TH_CONCAT_STRING_3(torch.,Real,Storage)); | ||
void *src; | ||
if( (src = luaT_toudata(L, 2, TH_CONCAT_STRING_3(torch.,Real,Storage) ))) | ||
THStorage_(copy)(storage, src); | ||
else if( (src = luaT_toudata(L, 2, "torch.ByteStorage")) ) | ||
THStorage_(copyByte)(storage, src); | ||
else if( (src = luaT_toudata(L, 2, "torch.CharStorage")) ) | ||
THStorage_(copyChar)(storage, src); | ||
else if( (src = luaT_toudata(L, 2, "torch.ShortStorage")) ) | ||
THStorage_(copyShort)(storage, src); | ||
else if( (src = luaT_toudata(L, 2, "torch.IntStorage")) ) | ||
THStorage_(copyInt)(storage, src); | ||
else if( (src = luaT_toudata(L, 2, "torch.LongStorage")) ) | ||
THStorage_(copyLong)(storage, src); | ||
else if( (src = luaT_toudata(L, 2, "torch.FloatStorage")) ) | ||
THStorage_(copyFloat)(storage, src); | ||
else if( (src = luaT_toudata(L, 2, "torch.DoubleStorage")) ) | ||
THStorage_(copyDouble)(storage, src); | ||
else if( (src = luaT_toudata(L, 2, "torch.HalfStorage")) ) | ||
THStorage_(copyHalf)(storage, src); | ||
else if( (src = luaT_toudata(L, 2, "torch.CudaStorage")) ) | ||
THStorage_(copyCudaFloat)(cutorch_getstate(L), storage, src); | ||
else if( (src = luaT_toudata(L, 2, "torch.CudaLongStorage")) ) | ||
THStorage_(copyCudaLong)(cutorch_getstate(L), storage, src); | ||
else if( (src = luaT_toudata(L, 2, "torch.CudaByteStorage")) ) | ||
THStorage_(copyCudaByte)(cutorch_getstate(L), storage, src); | ||
else if( (src = luaT_toudata(L, 2, "torch.CudaCharStorage")) ) | ||
THStorage_(copyCudaChar)(cutorch_getstate(L), storage, src); | ||
else if( (src = luaT_toudata(L, 2, "torch.CudaShortStorage")) ) | ||
THStorage_(copyCudaShort)(cutorch_getstate(L), storage, src); | ||
else if( (src = luaT_toudata(L, 2, "torch.CudaIntStorage")) ) | ||
THStorage_(copyCudaInt)(cutorch_getstate(L), storage, src); | ||
else if( (src = luaT_toudata(L, 2, "torch.CudaDoubleStorage")) ) | ||
THStorage_(copyCudaDouble)(cutorch_getstate(L), storage, src); | ||
#ifdef CUDA_HALF_TENSOR | ||
else if( (src = luaT_toudata(L, 2, "torch.CudaHalfStorage")) ) | ||
THStorage_(copyCudaHalf)(cutorch_getstate(L), storage, src); | ||
#endif | ||
else | ||
luaL_typerror(L, 2, "torch.*Storage"); | ||
|
||
lua_settop(L, 1); | ||
return 1; | ||
} | ||
|
||
void cutorch_StorageCopy_(init)(lua_State* L) | ||
{ | ||
// torch_Storage macro is defined in Storage.c produce the CudaTensor types | ||
// so I have to construct the normal torch types by hand | ||
luaT_pushmetatable(L, TH_CONCAT_STRING_3(torch.,Real,Storage)); | ||
lua_pushcfunction(L, TH_CONCAT_3(cutorch_,Real,Storage_copy)); | ||
lua_setfield(L, -2, "copy"); | ||
lua_pop(L, 1); | ||
} | ||
|
||
#endif |
Oops, something went wrong.