Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.egg-info/
2 changes: 1 addition & 1 deletion difflogic/compiled_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def compile(self, opt_level=1, save_lib_path=None, verbose=False):
"-shared",
"-fPIC",
"-O{}".format(opt_level),
"-march=native",
# "-march=native", # removed for compatibility with Apple Silicon: https://stackoverflow.com/questions/65966969/why-does-march-native-not-work-on-apple-m1
"-o",
lib_file.name,
c_file.name,
Expand Down
9 changes: 6 additions & 3 deletions difflogic/cuda/difflogic_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ __global__ void tensor_packbits_cuda_kernel(
) {
for ( // batch in b
auto col = blockIdx.x * blockDim.x + threadIdx.x;
col < t.size(1);
col < b.size(1);
col += blockDim.x * gridDim.x
) {

Expand All @@ -569,8 +569,11 @@ __global__ void tensor_packbits_cuda_kernel(
constexpr int bit_count = std::numeric_limits<unsigned_scalar_t>::digits;
val.signed_scalar = b[row][col];
for (unsigned int i = 0; i < bit_count; ++i) {
const unsigned_scalar_t bit_mask = static_cast<unsigned_scalar_t>(t[row][bit_count * col + i]) << i;
val.unsigned_scalar = val.unsigned_scalar | bit_mask;
const auto t_col = bit_count * col + i;
if (t_col < t.size(1)) {
const unsigned_scalar_t bit_mask = static_cast<unsigned_scalar_t>(t[row][t_col]) << i;
val.unsigned_scalar = val.unsigned_scalar | bit_mask;
}
}
b[row][col] = val.signed_scalar;
}
Expand Down