forked from zhanghang1989/PyTorch-Encoding
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1633f31
commit fa0e478
Showing
13 changed files
with
706 additions
and
26 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
Empty file.
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,12 @@ | ||
|
||
from torch.utils.ffi import _wrap_function | ||
from ._encoding_lib import lib as _lib, ffi as _ffi | ||
|
||
__all__ = [] | ||
def _import_symbols(locals): | ||
for symbol in dir(_lib): | ||
fn = getattr(_lib, symbol) | ||
locals[symbol] = _wrap_function(fn, _ffi) | ||
__all__.append(symbol) | ||
|
||
_import_symbols(locals()) |
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,18 @@ | ||
// The maximum number of threads in a block | ||
const int WARP_SIZE = 32; | ||
const int MAX_BLOCK_SIZE = 512; | ||
|
||
// Number of threads in a block given an input size up to MAX_BLOCK_SIZE | ||
static int getNumThreads(int nElem) { | ||
int threadSizes[5] = { 32, 64, 128, 256, MAX_BLOCK_SIZE }; | ||
for (int i = 0; i != 5; ++i) { | ||
if (nElem <= threadSizes[i]) { | ||
return threadSizes[i]; | ||
} | ||
} | ||
return MAX_BLOCK_SIZE; | ||
} | ||
|
||
__device__ __forceinline__ int getMSB(int val) { | ||
return 31 - __clz(val); | ||
} |
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
Oops, something went wrong.