Skip to content

Commit e279963

Browse files
peterbell10facebook-github-bot
authored andcommitted
Remove remaining THC code (pytorch#69039)
Summary: Pull Request resolved: pytorch#69039 Test Plan: Imported from OSS Reviewed By: anjali411 Differential Revision: D32872476 Pulled By: ngimel fbshipit-source-id: 7972aacc24aef9450fb59b707ed6396c501bcb31
1 parent 7407e3d commit e279963

35 files changed

+20
-289
lines changed

BUILD.bazel

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -389,27 +389,6 @@ filegroup(
389389
],
390390
)
391391

392-
filegroup(
393-
name = "thc_srcs_cu",
394-
srcs = [
395-
"aten/src/THC/THCReduceApplyUtils.cu.cc",
396-
"aten/src/THC/THCSortUtils.cu.cc",
397-
"aten/src/THC/THCTensor.cu.cc",
398-
"aten/src/THC/THCTensorCopy.cu.cc",
399-
"aten/src/THC/THCTensorMathScan.cu.cc",
400-
"aten/src/THC/THCTensorScatterGather.cu.cc",
401-
"aten/src/THC/THCTensorSort.cu.cc",
402-
"aten/src/THC/generated/THCTensorSortByte.cu.cc",
403-
"aten/src/THC/generated/THCTensorSortChar.cu.cc",
404-
"aten/src/THC/generated/THCTensorSortDouble.cu.cc",
405-
"aten/src/THC/generated/THCTensorSortFloat.cu.cc",
406-
"aten/src/THC/generated/THCTensorSortHalf.cu.cc",
407-
"aten/src/THC/generated/THCTensorSortInt.cu.cc",
408-
"aten/src/THC/generated/THCTensorSortLong.cu.cc",
409-
"aten/src/THC/generated/THCTensorSortShort.cu.cc",
410-
],
411-
)
412-
413392
filegroup(
414393
name = "aten_srcs_cu",
415394
srcs = [
@@ -550,9 +529,7 @@ cc_library(
550529
"aten/src/**/*.h",
551530
"aten/src/**/*.hpp",
552531
"aten/src/TH/**/*.cpp",
553-
"aten/src/THC/**/*.cpp",
554532
"aten/src/THC/*.cuh",
555-
"aten/src/THC/generic/*.cu.cc",
556533
],
557534
exclude = [
558535
"aten/src/ATen/Config.h",
@@ -692,7 +669,6 @@ cu_library(
692669
name = "aten_cuda",
693670
srcs = [
694671
":aten_srcs_cu",
695-
":thc_srcs_cu",
696672
],
697673
copts = ATEN_COPTS + torch_cuda_half_options,
698674
visibility = ["//visibility:public"],

CONTRIBUTING.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,6 @@ into the repo directory.
243243
* [aten](aten) - C++ tensor library for PyTorch (no autograd support)
244244
* [src](aten/src) - [README](aten/src/README.md)
245245
* [TH](aten/src/TH)
246-
[THC](aten/src/THC) - Legacy library code from the original
247-
Torch. Try not to add things here; we're slowly porting these to
248-
[native](aten/src/ATen/native).
249246
* generic - Contains actual implementations of operators,
250247
parametrized over `scalar_t`. Files here get compiled N times
251248
per supported scalar type in PyTorch.

aten/src/ATen/Context.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020

2121
namespace at {
2222

23-
Context::Context()
24-
: thc_state(nullptr, [](THCState* p) { /* no-op */ }),
25-
thh_state(nullptr, [](THHState* p) { /* no-op */ }) {}
23+
Context::Context() = default;
2624

2725
// TODO: This could be bad juju if someone calls globalContext() in the
2826
// destructor of an object with static lifetime.

aten/src/ATen/Context.h

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,28 +91,19 @@ class TORCH_API Context {
9191
}
9292
// defined in header so that getNonVariableType has ability to inline
9393
// call_once check. getNonVariableType is called fairly frequently
94-
THCState* lazyInitCUDA() {
94+
void lazyInitCUDA() {
9595
std::call_once(thc_init,[&] {
96-
thc_state = detail::getCUDAHooks().initCUDA();
96+
detail::getCUDAHooks().initCUDA();
9797
});
98-
return thc_state.get();
9998
}
100-
THHState* lazyInitHIP() {
99+
void lazyInitHIP() {
101100
std::call_once(thh_init,[&] {
102-
thh_state = detail::getHIPHooks().initHIP();
101+
detail::getHIPHooks().initHIP();
103102
});
104-
return thh_state.get();
105103
}
106104
static const at::cuda::NVRTC& getNVRTC() {
107105
return detail::getCUDAHooks().nvrtc();
108106
}
109-
THCState* getTHCState() {
110-
// AT_ASSERT(thc_state);
111-
return thc_state.get();
112-
}
113-
THHState* getTHHState() {
114-
return thh_state.get();
115-
}
116107

117108
static bool setFlushDenormal(bool on);
118109

@@ -261,8 +252,6 @@ class TORCH_API Context {
261252
#endif
262253
bool display_vmap_fallback_warnings_ = false;
263254
c10::optional<at::QEngine> quantized_engine = c10::nullopt;
264-
std::unique_ptr<THCState, void(*)(THCState*)> thc_state;
265-
std::unique_ptr<THHState, void(*)(THHState*)> thh_state;
266255

267256
Allocator* prev_allocator_ptr_{nullptr};
268257
};

aten/src/ATen/cuda/detail/CUDAHooks.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#include <c10/util/Exception.h>
1717
#include <c10/cuda/CUDACachingAllocator.h>
1818

19-
#include <THC/THCGeneral.h> // For THCState
20-
2119
#if AT_CUDNN_ENABLED()
2220
#include <ATen/cudnn/cudnn-wrapper.h>
2321
#endif
@@ -57,16 +55,8 @@ void set_magma_init_fn(void (*fn)()) {
5755
// NB: deleter is dynamic, because we need it to live in a separate
5856
// compilation unit (alt is to have another method in hooks, but
5957
// let's not if we don't need to!)
60-
std::unique_ptr<THCState, void (*)(THCState*)> CUDAHooks::initCUDA() const {
58+
void CUDAHooks::initCUDA() const {
6159
C10_LOG_API_USAGE_ONCE("aten.init.cuda");
62-
// NOTE: THCState is now an empty struct but this pointer is passed
63-
// to every THC function. So we can't remove it before the rest of THC.
64-
auto thc_state = std::unique_ptr<THCState, void (*)(THCState*)>(
65-
new THCState(),
66-
[](THCState* p) {
67-
delete p;
68-
});
69-
7060
// Force the update to enable unit testing. This code get executed before unit tests
7161
// have a chance to enable vitals.
7262
at::vitals::VitalsAPI.setVital("CUDA", "used", "true", /* force = */ true);
@@ -79,8 +69,6 @@ std::unique_ptr<THCState, void (*)(THCState*)> CUDAHooks::initCUDA() const {
7969
TORCH_INTERNAL_ASSERT(magma_init_fn != nullptr, "Cannot initilaize magma, init routine not set");
8070
magma_init_fn();
8171
#endif
82-
83-
return thc_state;
8472
}
8573

8674
const Generator& CUDAHooks::getDefaultCUDAGenerator(DeviceIndex device_index) const {

aten/src/ATen/cuda/detail/CUDAHooks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ TORCH_CUDA_CPP_API c10::optional<int64_t> getDeviceIndexWithPrimaryContext();
1919
// The real implementation of CUDAHooksInterface
2020
struct CUDAHooks : public at::CUDAHooksInterface {
2121
CUDAHooks(at::CUDAHooksArgs) {}
22-
std::unique_ptr<THCState, void(*)(THCState*)> initCUDA() const override;
22+
void initCUDA() const override;
2323
Device getDeviceFromPtr(void* data) const override;
2424
bool isPinnedPtr(void* data) const override;
2525
const Generator& getDefaultCUDAGenerator(DeviceIndex device_index = -1) const override;

aten/src/ATen/detail/CUDAHooksInterface.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
#include <functional>
1111
#include <memory>
1212

13-
// Forward-declares THCState
14-
struct THCState;
15-
1613
// Forward-declares at::cuda::NVRTC
1714
namespace at { namespace cuda {
1815
struct NVRTC;
@@ -73,7 +70,7 @@ struct TORCH_API CUDAHooksInterface {
7370
virtual ~CUDAHooksInterface() {}
7471

7572
// Initialize THCState and, transitively, the CUDA state
76-
virtual std::unique_ptr<THCState, void (*)(THCState*)> initCUDA() const {
73+
virtual void initCUDA() const {
7774
TORCH_CHECK(false, "Cannot initialize CUDA without ATen_cuda library. ", CUDA_HELP);
7875
}
7976

aten/src/ATen/detail/HIPHooksInterface.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
#include <functional>
1111
#include <memory>
1212

13-
// Forward-declares THHState
14-
struct THHState;
15-
1613
namespace at {
1714
class Context;
1815
}
@@ -29,8 +26,8 @@ struct TORCH_API HIPHooksInterface {
2926
// squelch -Werror=non-virtual-dtor
3027
virtual ~HIPHooksInterface() {}
3128

32-
// Initialize THHState and, transitively, the HIP state
33-
virtual std::unique_ptr<THHState, void (*)(THHState*)> initHIP() const {
29+
// Initialize the HIP library state
30+
virtual void initHIP() const {
3431
AT_ERROR("Cannot initialize HIP without ATen_hip library.");
3532
}
3633

aten/src/ATen/miopen/Exceptions.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#include <stdexcept>
66
#include <sstream>
77

8-
struct THCState;
9-
108
namespace at { namespace native {
119

1210
class miopen_exception : public std::runtime_error {

aten/src/ATen/miopen/Utils.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include <ATen/ATen.h>
4-
#include <aten/src/THH/THH.h>
54
#include <ATen/miopen/miopen-wrapper.h>
65
#include <ATen/miopen/Handle.h>
76

aten/src/ATen/native/miopen/Conv_miopen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ std::tuple<at::Tensor,at::Tensor,at::Tensor> miopen_depthwise_convolution_backwa
114114
#include <ATen/native/ConvUtils.h>
115115
#include <c10/util/irange.h>
116116

117-
#include <c10/cuda/CUDACachingAllocator.h>
117+
#include <c10/hip/HIPCachingAllocator.h>
118118

119119
#include <functional>
120120
#include <iterator>

aten/src/ATen/native/miopen/RNN_miopen.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ namespace at { namespace native {
3737

3838
#else // AT_ROCM_ENABLED()
3939

40-
#include <aten/src/THH/THH.h>
41-
4240
#include <ATen/miopen/miopen-wrapper.h>
4341
#include <ATen/miopen/Descriptors.h>
4442
#include <ATen/miopen/Types.h>

aten/src/THC/CMakeLists.txt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,8 @@ set(ATen_CUDA_INCLUDE ${ATen_CUDA_INCLUDE}
22
"${CMAKE_CURRENT_SOURCE_DIR}"
33
PARENT_SCOPE)
44

5-
set(ATen_CUDA_SRCS ${ATen_CUDA_SRCS}
6-
${CMAKE_CURRENT_SOURCE_DIR}/THCTensor.cpp
7-
PARENT_SCOPE)
8-
95
install(FILES
10-
THC.h
11-
THCGeneral.h
12-
THCGeneral.hpp
13-
THCTensor.h
146
THCAtomics.cuh
7+
THCDeviceUtils.cuh
158
THCGenerateByteType.h
16-
# See Note [TH abstraction violation]
17-
THCTensor.hpp
189
DESTINATION "${ATEN_INSTALL_INCLUDE_SUBDIR}/THC")
19-
20-
install(FILES
21-
generic/THCTensor.cpp
22-
generic/THCTensor.h
23-
DESTINATION "${ATEN_INSTALL_INCLUDE_SUBDIR}/THC/generic")

aten/src/THC/THC.h

Lines changed: 0 additions & 8 deletions
This file was deleted.

aten/src/THC/THCGeneral.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

aten/src/THC/THCGeneral.hpp

Lines changed: 0 additions & 3 deletions
This file was deleted.

aten/src/THC/THCTensor.cpp

Lines changed: 0 additions & 14 deletions
This file was deleted.

aten/src/THC/THCTensor.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

aten/src/THC/THCTensor.hpp

Lines changed: 0 additions & 18 deletions
This file was deleted.

aten/src/THC/generic/THCTensor.cpp

Lines changed: 0 additions & 24 deletions
This file was deleted.

aten/src/THC/generic/THCTensor.h

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)