Skip to content

Commit

Permalink
Move REGISTER_CUDA_HOOKS to cpp file. (#7630)
Browse files Browse the repository at this point in the history
It's going to define a static variable, and this was a loaded
footgun if another C++ file directly included this header.

Signed-off-by: Edward Z. Yang <[email protected]>
  • Loading branch information
ezyang authored May 29, 2018
1 parent fb59ce3 commit bc8a92d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 6 additions & 0 deletions aten/src/ATen/cuda/detail/CUDAHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,10 @@ int CUDAHooks::getNumGPUs() const {
return count;
}

// Sigh, the registry doesn't support namespaces :(
using at::RegistererCUDAHooksRegistry;
using at::CUDAHooksRegistry;

REGISTER_CUDA_HOOKS(CUDAHooks);

}}} // namespace at::cuda::detail
9 changes: 3 additions & 6 deletions aten/src/ATen/cuda/detail/CUDAHooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#include <ATen/Generator.h>

// TODO: No need to have this whole header, we can just put it all in
// the cpp file

namespace at { namespace cuda { namespace detail {

// The real implementation of CUDAHooksInterface
Expand All @@ -24,10 +27,4 @@ struct CUDAHooks : public at::CUDAHooksInterface {
int getNumGPUs() const override;
};

// Sigh, the registry doesn't support namespaces :(
using at::RegistererCUDAHooksRegistry;
using at::CUDAHooksRegistry;

REGISTER_CUDA_HOOKS(CUDAHooks);

}}} // at::cuda::detail

0 comments on commit bc8a92d

Please sign in to comment.