mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-08 07:39:33 +01:00
Remove THTensor (#69040)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/69040 Test Plan: Imported from OSS Reviewed By: anjali411 Differential Revision: D32872478 Pulled By: ngimel fbshipit-source-id: f93e16509d64308d91e374744410a6a811e7f4e3
This commit is contained in:
parent
531b045446
commit
9962bfb3c9
|
|
@ -352,7 +352,6 @@ filegroup(
|
||||||
name = "th_srcs",
|
name = "th_srcs",
|
||||||
srcs = [
|
srcs = [
|
||||||
"aten/src/TH/THGeneral.cpp",
|
"aten/src/TH/THGeneral.cpp",
|
||||||
"aten/src/TH/THTensor.cpp",
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ set(hdr
|
||||||
|
|
||||||
set(ATen_TH_SRCS
|
set(ATen_TH_SRCS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/THGeneral.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/THGeneral.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/THTensor.cpp
|
|
||||||
)
|
)
|
||||||
# Remember that PARENT_SCOPE variables are not in the current scope
|
# Remember that PARENT_SCOPE variables are not in the current scope
|
||||||
set(ATen_TH_SRCS ${ATen_TH_SRCS} PARENT_SCOPE)
|
set(ATen_TH_SRCS ${ATen_TH_SRCS} PARENT_SCOPE)
|
||||||
|
|
@ -34,13 +33,5 @@ install(FILES
|
||||||
TH.h
|
TH.h
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/THGeneral.h
|
${CMAKE_CURRENT_BINARY_DIR}/THGeneral.h
|
||||||
THGenerateByteType.h
|
THGenerateByteType.h
|
||||||
THTensor.h
|
|
||||||
THHalf.h
|
THHalf.h
|
||||||
THTensor.hpp
|
|
||||||
DESTINATION "${ATEN_INSTALL_INCLUDE_SUBDIR}/TH")
|
DESTINATION "${ATEN_INSTALL_INCLUDE_SUBDIR}/TH")
|
||||||
|
|
||||||
install(FILES
|
|
||||||
generic/THTensor.cpp
|
|
||||||
generic/THTensor.h
|
|
||||||
# See Note [TH abstraction violation]
|
|
||||||
DESTINATION "${ATEN_INSTALL_INCLUDE_SUBDIR}/TH/generic")
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,5 @@
|
||||||
#define TH_INC
|
#define TH_INC
|
||||||
|
|
||||||
#include <TH/THGeneral.h>
|
#include <TH/THGeneral.h>
|
||||||
#include <TH/THTensor.h>
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
#include <TH/THTensor.hpp>
|
|
||||||
|
|
||||||
// NOLINTNEXTLINE(bugprone-suspicious-include)
|
|
||||||
#include <TH/generic/THTensor.cpp>
|
|
||||||
#include <TH/THGenerateByteType.h>
|
|
||||||
|
|
||||||
#include <ATen/native/Resize.h>
|
|
||||||
#include <ATen/TensorUtils.h>
|
|
||||||
|
|
||||||
#include <numeric>
|
|
||||||
|
|
||||||
// NB: This is NOT valid on UndefinedTensorImpl
|
|
||||||
void THTensor_free(THTensor *self)
|
|
||||||
{
|
|
||||||
if (!self) return;
|
|
||||||
c10::raw::intrusive_ptr::decref(self);
|
|
||||||
}
|
|
||||||
|
|
||||||
void THTensor_setStorage(THTensor *self, c10::StorageImpl *storage_, ptrdiff_t storageOffset_, at::IntArrayRef size_, at::IntArrayRef stride_) {
|
|
||||||
c10::raw::intrusive_ptr::incref(storage_);
|
|
||||||
THTensor_wrap(self).set_(at::Storage(c10::intrusive_ptr<at::StorageImpl>::reclaim(storage_)), storageOffset_, size_, stride_);
|
|
||||||
}
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
#ifndef TH_TENSOR_INC
|
|
||||||
#define TH_TENSOR_INC
|
|
||||||
|
|
||||||
#include <TH/THGeneral.h>
|
|
||||||
|
|
||||||
#define THTensor_(NAME) TH_CONCAT_4(TH,Real,Tensor_,NAME)
|
|
||||||
|
|
||||||
/* basics */
|
|
||||||
#include <TH/generic/THTensor.h>
|
|
||||||
#include <TH/THGenerateByteType.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// STOP!!! Thinking of including this header directly? Please
|
|
||||||
// read Note [TH abstraction violation]
|
|
||||||
|
|
||||||
#include <TH/THTensor.h>
|
|
||||||
#include <c10/core/StorageImpl.h>
|
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
#include <ATen/ATen.h>
|
|
||||||
|
|
||||||
// Returns a Tensor given a TensorImpl. The TensorImpl remains valid after the
|
|
||||||
// the Tensor is destroyed.
|
|
||||||
inline at::Tensor THTensor_wrap(THTensor* tensor) {
|
|
||||||
c10::raw::intrusive_ptr::incref(tensor);
|
|
||||||
return at::Tensor(c10::intrusive_ptr<at::TensorImpl>::reclaim(tensor));
|
|
||||||
}
|
|
||||||
|
|
||||||
TH_API void THTensor_free(THTensor *self);
|
|
||||||
|
|
||||||
TH_CPP_API void THTensor_setStorage(THTensor *self, c10::StorageImpl *storage_, ptrdiff_t storageOffset_, at::IntArrayRef size_, at::IntArrayRef stride_);
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
#ifndef TH_GENERIC_FILE
|
|
||||||
#define TH_GENERIC_FILE "TH/generic/THTensor.cpp"
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <ATen/InferSize.h>
|
|
||||||
#include <ATen/NativeFunctions.h>
|
|
||||||
#include <new>
|
|
||||||
#include <ATen/NamedTensorUtils.h>
|
|
||||||
#include <ATen/MemoryOverlap.h>
|
|
||||||
|
|
||||||
/**** creation methods ****/
|
|
||||||
|
|
||||||
THTensor *THTensor_(newWithStorage1d)(c10::StorageImpl *storage, ptrdiff_t storageOffset,
|
|
||||||
int64_t size0, int64_t stride0)
|
|
||||||
{
|
|
||||||
c10::raw::intrusive_ptr::incref(storage);
|
|
||||||
THTensor* self = c10::make_intrusive<at::TensorImpl, at::UndefinedTensorImpl>(
|
|
||||||
c10::intrusive_ptr<at::StorageImpl>::reclaim(storage),
|
|
||||||
at::DispatchKey::CPU,
|
|
||||||
#ifdef THQUANTIZED
|
|
||||||
caffe2::TypeMeta::Make<quantized_t>()
|
|
||||||
#else
|
|
||||||
caffe2::TypeMeta::Make<scalar_t>()
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
.release();
|
|
||||||
THTensor_setStorage(self, storage, storageOffset, {size0}, {stride0});
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
#ifndef TH_GENERIC_FILE
|
|
||||||
#define TH_GENERIC_FILE "TH/generic/THTensor.h"
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* a la lua? dim, storageoffset, ... et les methodes ? */
|
|
||||||
|
|
||||||
#include <c10/core/TensorImpl.h>
|
|
||||||
|
|
||||||
#define THTensor at::TensorImpl
|
|
||||||
|
|
||||||
// These used to be distinct types; for some measure of backwards compatibility and documentation
|
|
||||||
// alias these to the single THTensor type.
|
|
||||||
#define THFloatTensor THTensor
|
|
||||||
#define THDoubleTensor THTensor
|
|
||||||
#define THHalfTensor THTensor
|
|
||||||
#define THByteTensor THTensor
|
|
||||||
#define THCharTensor THTensor
|
|
||||||
#define THShortTensor THTensor
|
|
||||||
#define THIntTensor THTensor
|
|
||||||
#define THLongTensor THTensor
|
|
||||||
#define THBoolTensor THTensor
|
|
||||||
#define THBFloat16Tensor THTensor
|
|
||||||
#define THComplexFloatTensor THTensor
|
|
||||||
#define THComplexDoubleTensor THTensor
|
|
||||||
|
|
||||||
/**** creation methods ****/
|
|
||||||
TH_API THTensor *THTensor_(newWithStorage1d)(c10::StorageImpl *storage_, ptrdiff_t storageOffset_,
|
|
||||||
int64_t size0_, int64_t stride0_);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1250,7 +1250,6 @@ aten_native_source_non_codegen_list = [
|
||||||
"aten/src/ATen/native/sparse/SparseUnaryOps.cpp",
|
"aten/src/ATen/native/sparse/SparseUnaryOps.cpp",
|
||||||
"aten/src/ATen/native/sparse/SparseCsrTensorMath.cpp",
|
"aten/src/ATen/native/sparse/SparseCsrTensorMath.cpp",
|
||||||
"aten/src/TH/THGeneral.cpp",
|
"aten/src/TH/THGeneral.cpp",
|
||||||
"aten/src/TH/THTensor.cpp",
|
|
||||||
"aten/src/ATen/native/utils/Factory.cpp",
|
"aten/src/ATen/native/utils/Factory.cpp",
|
||||||
"aten/src/ATen/native/xnnpack/Activation.cpp",
|
"aten/src/ATen/native/xnnpack/Activation.cpp",
|
||||||
"aten/src/ATen/native/xnnpack/ChannelShuffle.cpp",
|
"aten/src/ATen/native/xnnpack/ChannelShuffle.cpp",
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ namespace torch {
|
||||||
|
|
||||||
struct THPVoidTensor {
|
struct THPVoidTensor {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
THVoidTensor *cdata;
|
c10::TensorImpl *cdata;
|
||||||
char device_type;
|
char device_type;
|
||||||
char data_type;
|
char data_type;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#include <torch/csrc/python_headers.h>
|
#include <torch/csrc/python_headers.h>
|
||||||
#include <TH/TH.h>
|
#include <TH/TH.h>
|
||||||
#include <TH/THTensor.hpp>
|
|
||||||
|
|
||||||
#include <torch/csrc/Export.h>
|
#include <torch/csrc/Export.h>
|
||||||
|
|
||||||
|
|
@ -17,15 +16,6 @@
|
||||||
#define PyInt_Type PyLong_Type
|
#define PyInt_Type PyLong_Type
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// By default, don't specify library state (TH doesn't use one)
|
|
||||||
#define LIBRARY_STATE
|
|
||||||
#define LIBRARY_STATE_NOARGS
|
|
||||||
#define LIBRARY_STATE_TYPE
|
|
||||||
#define LIBRARY_STATE_TYPE_NOARGS
|
|
||||||
|
|
||||||
#define THWTensor THTensor
|
|
||||||
#define THWTensor_(NAME) THTensor_(NAME)
|
|
||||||
|
|
||||||
#include <torch/csrc/Exceptions.h>
|
#include <torch/csrc/Exceptions.h>
|
||||||
#include <torch/csrc/Generator.h>
|
#include <torch/csrc/Generator.h>
|
||||||
#include <torch/csrc/Module.h>
|
#include <torch/csrc/Module.h>
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,4 @@
|
||||||
|
|
||||||
template <typename T> struct THPTypeInfo {};
|
template <typename T> struct THPTypeInfo {};
|
||||||
|
|
||||||
namespace torch {
|
|
||||||
|
|
||||||
typedef THTensor THVoidTensor;
|
|
||||||
|
|
||||||
} // namespace torch
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,6 @@
|
||||||
#include <structmember.h>
|
#include <structmember.h>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
// See Note [TH abstraction violation]
|
|
||||||
// - Used to get at allocator from storage
|
|
||||||
#include <TH/THTensor.hpp>
|
|
||||||
#include <torch/csrc/cuda/THCP.h>
|
#include <torch/csrc/cuda/THCP.h>
|
||||||
|
|
||||||
#include <torch/csrc/cuda/override_macros.h>
|
#include <torch/csrc/cuda/override_macros.h>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#include <torch/csrc/cuda/undef_macros.h>
|
#include <torch/csrc/cuda/undef_macros.h>
|
||||||
|
|
||||||
#define THPStoragePtr THCPStoragePtr
|
#define THPStoragePtr THCPStoragePtr
|
||||||
#define THWTensorPtr THCTensorPtr
|
|
||||||
#define THPTensorPtr THCPTensorPtr
|
#define THPTensorPtr THCPTensorPtr
|
||||||
|
|
||||||
#define THWTensor THCTensor
|
#define THWTensor THCTensor
|
||||||
|
|
@ -39,11 +38,4 @@
|
||||||
#define THSPTensorStateless THCSPTensorStateless
|
#define THSPTensorStateless THCSPTensorStateless
|
||||||
|
|
||||||
|
|
||||||
#define LIBRARY_STATE_NOARGS state
|
|
||||||
#define LIBRARY_STATE state,
|
|
||||||
#define LIBRARY_STATE_TYPE THCState*,
|
|
||||||
#define LIBRARY_STATE_TYPE_NOARGS THCState*
|
|
||||||
#define TH_GENERIC_FILE THC_GENERIC_FILE
|
#define TH_GENERIC_FILE THC_GENERIC_FILE
|
||||||
|
|
||||||
#define THHostTensor TH_CONCAT_3(TH,Real,Tensor)
|
|
||||||
#define THHostTensor_(NAME) TH_CONCAT_4(TH,Real,Tensor_,NAME)
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,4 @@
|
||||||
#undef TH_GENERIC_FILE
|
#undef TH_GENERIC_FILE
|
||||||
#undef LIBRARY_STATE
|
|
||||||
#undef LIBRARY_STATE_NOARGS
|
|
||||||
#undef LIBRARY_STATE_TYPE
|
|
||||||
#undef LIBRARY_STATE_TYPE_NOARGS
|
|
||||||
|
|
||||||
#undef THPTensor_
|
#undef THPTensor_
|
||||||
#undef THPTensor_stateless_
|
#undef THPTensor_stateless_
|
||||||
|
|
@ -21,13 +17,11 @@
|
||||||
#undef THPStorageClass
|
#undef THPStorageClass
|
||||||
#undef THPStorageType
|
#undef THPStorageType
|
||||||
|
|
||||||
#undef THWTensor
|
|
||||||
#undef THWTensor_
|
|
||||||
|
|
||||||
#undef THPStoragePtr
|
#undef THPStoragePtr
|
||||||
#undef THWTensorPtr
|
|
||||||
#undef THPTensorPtr
|
#undef THPTensorPtr
|
||||||
|
|
||||||
|
#undef THWTensor
|
||||||
|
#undef THWTensor_
|
||||||
|
|
||||||
#undef THSPTensor_
|
#undef THSPTensor_
|
||||||
#undef THSPTensor_stateless_
|
#undef THSPTensor_stateless_
|
||||||
|
|
@ -41,7 +35,3 @@
|
||||||
#undef THSPTensorType
|
#undef THSPTensorType
|
||||||
|
|
||||||
#undef THSPTensorPtr
|
#undef THSPTensorPtr
|
||||||
|
|
||||||
|
|
||||||
#undef THHostTensor
|
|
||||||
#undef THHostTensor_
|
|
||||||
|
|
|
||||||
|
|
@ -176,13 +176,6 @@ bool maybeThrowBackCompatKeepdimWarn(char *func) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
|
||||||
void THPPointer<THTensor>::free() {
|
|
||||||
if (ptr) {
|
|
||||||
c10::raw::intrusive_ptr::decref(ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void THPPointer<THPStorage>::free() {
|
void THPPointer<THPStorage>::free() {
|
||||||
if (ptr)
|
if (ptr)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user