Skip to content

Commit

Permalink
fix issue 320
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthijs Douze committed Jan 31, 2018
1 parent 4fe9204 commit df2edbe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gpu/impl/BroadcastSum.cu
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ __global__ void sumAlongColumns(Tensor<T, 1, true> input,

if (endRow) {
for (int row = rowStart; row < output.getSize(0); ++row) {
T out = output[row][col].ldg();
T out = output[row][col];
out = Math<T>::add(out, val);
output[row][col] = out;
}
Expand All @@ -57,7 +57,7 @@ __global__ void sumAlongColumns(Tensor<T, 1, true> input,
for (int row = rowStart; row < rowEnd; row += kRowUnroll) {
#pragma unroll
for (int i = 0; i < kRowUnroll; ++i) {
rows[i] = output[row + i][col].ldg();
rows[i] = output[row + i][col];
}

#pragma unroll
Expand Down Expand Up @@ -86,7 +86,7 @@ __global__ void sumAlongColumns(Tensor<T, 1, true> input,
for (int row = rowStart; row < output.getSize(0); ++row) {
#pragma unroll
for (int i = 0; i < kColLoad; ++i) {
T out = output[row][col + i * blockDim.x].ldg();
T out = output[row][col + i * blockDim.x];
out = Math<T>::add(out, val[i]);
output[row][col + i * blockDim.x] = out;
}
Expand All @@ -100,7 +100,7 @@ __global__ void sumAlongColumns(Tensor<T, 1, true> input,
#pragma unroll
for (int j = 0; j < kColLoad; ++j) {
rows[i * kColLoad + j] =
output[row + i][col + j * blockDim.x].ldg();
output[row + i][col + j * blockDim.x];
}
}

Expand Down
5 changes: 5 additions & 0 deletions gpu/utils/Tensor-inl.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,11 @@ Tensor<T, Dim, InnerContig, IndexT, PtrTraits>::canCastResize() const {
static_assert(sizeof(U) >= sizeof(T), "only handles greater sizes");
constexpr int kMultiple = sizeof(U) / sizeof(T);

// Ensure that the base pointer is sizeof(U) aligned
if (((uintptr_t) data_) % sizeof(U) != 0) {
return false;
}

// Check all outer strides
for (int i = 0; i < Dim - 1; ++i) {
if (stride_[i] % kMultiple != 0) {
Expand Down

0 comments on commit df2edbe

Please sign in to comment.