Skip to content
Merged
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
2 changes: 1 addition & 1 deletion extension_cpp/csrc/cuda/muladd.cu
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ at::Tensor mymul_cuda(const at::Tensor& a, const at::Tensor& b) {

__global__ void add_kernel(int numel, const float* a, const float* b, float* result) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < numel) result[idx] = a[idx] * b[idx];
if (idx < numel) result[idx] = a[idx] + b[idx];
}

void myadd_out_cuda(const at::Tensor& a, const at::Tensor& b, at::Tensor& out) {
Expand Down
7 changes: 7 additions & 0 deletions test/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ def _test_correctness(self, device):
expected = torch.add(*args[:2])
torch.testing.assert_close(result, expected)

def test_correctness_cpu(self):
self._test_correctness("cpu")

@unittest.skipIf(not torch.cuda.is_available(), "requires cuda")
def test_correctness_cuda(self):
self._test_correctness("cuda")

def _opcheck(self, device):
# Use opcheck to check for incorrect usage of operator registration APIs
samples = self.sample_inputs(device, requires_grad=True)
Expand Down