Skip to content

Commit

Permalink
fix misaligned access #56325 (#56403)
Browse files Browse the repository at this point in the history
Summary:
CC ngimel ptrblck
ref: #56325

Pull Request resolved: #56403

Reviewed By: mruberry

Differential Revision: D27866625

Pulled By: ngimel

fbshipit-source-id: 9dff0e9749f8de57fac6a653f685c14854611a02
  • Loading branch information
eqy authored and facebook-github-bot committed Apr 20, 2021
1 parent 92d24e3 commit 42f0fe1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion aten/src/ATen/native/cuda/SoftMax.cu
Expand Up @@ -669,7 +669,7 @@ cunn_SoftMaxBackward(scalar_t *gradInput, outscalar_t *output, outscalar_t *grad
const int grad_output_shift = ((uint64_t)gradOutput) % ALIGN_BYTES / sizeof(outscalar_t);

accscalar_t threadSum = ilpReduce<AddFloat, ILP, outscalar_t, accscalar_t>(
shift, gradOutput, classes, AddFloat<outscalar_t, accscalar_t>(), accscalar_t(0));
grad_output_shift, gradOutput, classes, AddFloat<outscalar_t, accscalar_t>(), accscalar_t(0));
accscalar_t sum_k = blockReduce<Add, accscalar_t>(
sdata, threadSum, Add<accscalar_t>(), accscalar_t(0));

Expand Down
3 changes: 2 additions & 1 deletion test/test_nn.py
Expand Up @@ -13272,7 +13272,8 @@ def test_softmax_results(self, device, dtype):
for dim in [0, 1]:
ref_output = fn(ref_input, dtype=torch.float, dim=dim)
output = fn(input, dtype=torch.float, dim=dim)
grad_output = torch.rand_like(output)
grad_output = torch.rand(size, device=device, dtype=dtype)
grad_output = grad_output[shift[0]:, shift[1]:]
ref_grad_output = grad_output.clone().cpu().detach()
grad_input, = torch.autograd.grad(output, input, grad_outputs=(grad_output), create_graph=True)
ref_grad_input, = torch.autograd.grad(ref_output, ref_input,
Expand Down

0 comments on commit 42f0fe1

Please sign in to comment.