Skip to content

Commit

Permalink
add macro for error message when kaolin not built with CUDA (NVIDIAGa…
Browse files Browse the repository at this point in the history
…meWorks#471)

Signed-off-by: Clement Fuji Tsang <[email protected]>
  • Loading branch information
Caenorst authored Nov 16, 2021
1 parent 002dcdf commit 93d1902
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ void foo_cuda_impl(
at::Tensor foo_cuda(
at::Tensor lhs,
at::Tensor rhs) {
#if WITH_CUDA
at::TensorArg lhs_arg{lhs, "lhs", 1}, rhs_arg{rhs, "rhs", 2};
at::checkSameGPU("foo_cuda", lhs_arg, rhs_arg);
at::checkAllContiguous("foo_cuda", {lhs_arg, rhs_arg});
Expand All @@ -153,12 +152,13 @@ at::Tensor foo_cuda(

at::Tensor output = at::zeros_like(lhs);

#if WITH_CUDA
foo_cuda_impl(lhs, rhs, output);

return output;
#else
AT_ERROR("In foo_cuda: Kaolin built without CUDA, cannot run with GPU tensors");
KAOLIN_NO_CUDA_ERROR(__func__);
#endif // WITH_CUDA
return output;
}

} // namespace kaolin
Expand Down
4 changes: 4 additions & 0 deletions kaolin/csrc/check.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@
TORCH_CHECK(x.sizes() == std::vector<int64_t>({__VA_ARGS__}), \
#x " must of size {" #__VA_ARGS__ "}")

#define KAOLIN_NO_CUDA_ERROR(func_name) \
AT_ERROR("In ", func_name, ": Kaolin built without CUDA, " \
"cannot run with GPU tensors")

#endif // KAOLIN_CHECK_H_

0 comments on commit 93d1902

Please sign in to comment.