Skip to content

Commit

Permalink
Torch rename (pytorch#20774)
Browse files Browse the repository at this point in the history
Summary:
This renames the CMake `caffe2` target to `torch`, as well as renaming `caffe2_gpu` to `torch_gpu` (and likewise for other gpu target variants).  Many intermediate variables that don't manifest as artifacts of the build remain for now with the "caffe2" name; a complete purge of `caffe2` from CMake variable names is beyond the scope of this PR.

The shell `libtorch` library that had been introduced as a stopgap in pytorch#17783 is again flattened in this PR.
Pull Request resolved: pytorch#20774

Differential Revision: D15769965

Pulled By: kostmo

fbshipit-source-id: b86e8c410099f90be0468e30176207d3ad40c821
  • Loading branch information
kostmo authored and facebook-github-bot committed Jun 13, 2019
1 parent e9121e2 commit 49481d5
Show file tree
Hide file tree
Showing 29 changed files with 139 additions and 281 deletions.
22 changes: 3 additions & 19 deletions aten/src/ATen/cuda/ATenCUDAGeneral.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,6 @@
#include <cuda_runtime.h>
#include <cuda_fp16.h>

#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
#include <c10/macros/Export.h>

#define AT_CUDA_API CAFFE2_API
10 changes: 4 additions & 6 deletions aten/src/ATen/cuda/CUDAEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ 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
CUDAEvent(unsigned int flags = DEFAULT_FLAGS)
: flags_{flags} { }
// Default value for `flags` is specified below - it's cudaEventDisableTiming
CUDAEvent() {}
CUDAEvent(unsigned int flags) : flags_{flags} {}

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

private:
unsigned int flags_ = DEFAULT_FLAGS;
unsigned int flags_ = cudaEventDisableTiming;
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

namespace at { namespace cuda {

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

}} // namespace at::cuda
2 changes: 1 addition & 1 deletion aten/src/TH/generic/THVectorDispatch.cpp
Original file line number Diff line number Diff line change
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
TH_API void THVector_(adds)(scalar_t *r_, const scalar_t *t, const scalar_t value, const ptrdiff_t n) {
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: 3 additions & 12 deletions aten/src/THC/THCGeneral.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,9 @@

# define THC_EXTERNC extern "C"

#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
// 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

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

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

target_include_directories(
c10_cuda PUBLIC
Expand Down
4 changes: 3 additions & 1 deletion c10/util/Optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,9 @@ class optional : private OptionalBase<T> {
return contained_val();
}

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

0 comments on commit 49481d5

Please sign in to comment.