Skip to content

Commit

Permalink
Revert "Torch rename (pytorch#20774)"
Browse files Browse the repository at this point in the history
This reverts commit 49481d5.
  • Loading branch information
kostmo committed Jun 13, 2019
1 parent 5485f09 commit a11beb6
Show file tree
Hide file tree
Showing 29 changed files with 281 additions and 139 deletions.
22 changes: 19 additions & 3 deletions aten/src/ATen/cuda/ATenCUDAGeneral.h
Expand Up @@ -4,6 +4,22 @@
#include <cuda_runtime.h>
#include <cuda_fp16.h>

#include <c10/macros/Export.h>

#define AT_CUDA_API CAFFE2_API
#ifdef _WIN32
#if !defined(AT_CORE_STATIC_WINDOWS)
# if defined(ATen_cuda_EXPORTS) || defined(caffe2_gpu_EXPORTS) || defined(caffe2_hip_EXPORTS) || defined(CAFFE2_CUDA_BUILD_MAIN_LIB)
# define AT_CUDA_API __declspec(dllexport)
# else
# define AT_CUDA_API __declspec(dllimport)
# endif
#else
# define AT_CUDA_API
#endif
#elif defined(__GNUC__)
#if defined(ATen_cuda_EXPORTS) || defined(caffe2_gpu_EXPORTS) || defined(caffe2_hip_EXPORTS)
#define AT_CUDA_API __attribute__((__visibility__("default")))
#else
#define AT_CUDA_API
#endif
#else
# define AT_CUDA_API
#endif
10 changes: 6 additions & 4 deletions aten/src/ATen/cuda/CUDAEvent.h
Expand Up @@ -25,10 +25,12 @@ namespace at { namespace cuda {
* Later streams that record the event must match this device.
*/
struct AT_CUDA_API CUDAEvent {
// Constants
static constexpr unsigned int DEFAULT_FLAGS = cudaEventDisableTiming;

// Constructors
// Default value for `flags` is specified below - it's cudaEventDisableTiming
CUDAEvent() {}
CUDAEvent(unsigned int flags) : flags_{flags} {}
CUDAEvent(unsigned int flags = DEFAULT_FLAGS)
: flags_{flags} { }

CUDAEvent(
DeviceIndex device_index, const cudaIpcEventHandle_t* handle) {
Expand Down Expand Up @@ -159,7 +161,7 @@ struct AT_CUDA_API CUDAEvent {
}

private:
unsigned int flags_ = cudaEventDisableTiming;
unsigned int flags_ = DEFAULT_FLAGS;
bool is_created_ = false;
bool was_recorded_ = false;
DeviceIndex device_index_ = -1;
Expand Down
2 changes: 1 addition & 1 deletion aten/src/ATen/cuda/PinnedMemoryAllocator.h
Expand Up @@ -4,6 +4,6 @@

namespace at { namespace cuda {

CAFFE2_API at::Allocator* getPinnedMemoryAllocator();
at::Allocator* getPinnedMemoryAllocator();

}} // namespace at::cuda
2 changes: 1 addition & 1 deletion aten/src/TH/generic/THVectorDispatch.cpp
Expand Up @@ -89,7 +89,7 @@ static FunctionDescription THVector_(adds_DISPATCHTABLE)[] = {
FUNCTION_IMPL(THVector_(adds_DEFAULT), SIMDExtension_DEFAULT)
};
// Dispatch stubs that just call the pointers
void THVector_(adds)(scalar_t *r_, const scalar_t *t, const scalar_t value, const ptrdiff_t n) {
TH_API void THVector_(adds)(scalar_t *r_, const scalar_t *t, const scalar_t value, const ptrdiff_t n) {
THVector_(adds_DISPATCHPTR)(r_, t, value, n);
}

Expand Down
15 changes: 12 additions & 3 deletions aten/src/THC/THCGeneral.h.in
Expand Up @@ -20,9 +20,18 @@

# define THC_EXTERNC extern "C"

// TH & THC are now part of the same library as ATen and Caffe2
#define THC_API THC_EXTERNC CAFFE2_API
#define THC_CLASS CAFFE2_API
#ifdef _WIN32
# if defined(ATen_cuda_EXPORTS) || defined(caffe2_gpu_EXPORTS) || defined(CAFFE2_CUDA_BUILD_MAIN_LIB)
# define THC_API THC_EXTERNC __declspec(dllexport)
# define THC_CLASS __declspec(dllexport)
# else
# define THC_API THC_EXTERNC __declspec(dllimport)
# define THC_CLASS __declspec(dllimport)
# endif
#else
# define THC_API THC_EXTERNC
# define THC_CLASS
#endif

#ifndef THAssert
#define THAssert(exp) \
Expand Down
2 changes: 1 addition & 1 deletion c10/cuda/CMakeLists.txt
Expand Up @@ -47,7 +47,7 @@ endif()
# ---[ Dependency of c10_cuda
target_link_libraries(c10_cuda PUBLIC c10)

target_link_libraries(c10_cuda INTERFACE torch::cudart)
target_link_libraries(c10_cuda INTERFACE caffe2::cudart)

target_include_directories(
c10_cuda PUBLIC
Expand Down
4 changes: 1 addition & 3 deletions c10/util/Optional.h
Expand Up @@ -597,9 +597,7 @@ class optional : private OptionalBase<T> {
return contained_val();
}

// This might be constexpr, but MSVC+cuda don't like combination of constexpr
// and throw.
T const& value() const {
constexpr T const& value() const {
return initialized()
? contained_val()
: (throw bad_optional_access("bad optional access"), contained_val());
Expand Down

0 comments on commit a11beb6

Please sign in to comment.