9 CUDATexture2D(
const at::Tensor &tensor,
const std::string &addressModeX,
const std::string &addressModeY);
13 [[nodiscard]]
unsigned long long Handle()
const;
39 : backingTensor(std::move(other.backingTensor)), arrayHandle(other.arrayHandle),
40 textureHandle(other.textureHandle) {
41 other.arrayHandle =
nullptr;
42 other.textureHandle = 0;
45 CUDATexture2D &operator=(CUDATexture2D &&other)
noexcept {
48 err = cudaDestroyTextureObject(textureHandle);
49 if (err != cudaSuccess) {
50 std::cerr <<
"cudaDestroyTextureObject failed: " << cudaGetErrorString(err) << std::endl;
54 std::cout <<
"[C++] CUDA texture " <<
static_cast<uint64_t
>(textureHandle) <<
" destroyed." << std::endl;
58 err = cudaFreeArray(arrayHandle);
59 if (err != cudaSuccess) {
60 std::cerr <<
"cudaFreeArray failed: " << cudaGetErrorString(err) << std::endl;
64 std::cout <<
"[C++] CUDA array freed." << std::endl;
67 backingTensor = std::move(other.backingTensor);
68 arrayHandle = other.arrayHandle;
69 textureHandle = other.textureHandle;
70 other.arrayHandle =
nullptr;
71 other.textureHandle = 0;
80 at::Tensor backingTensor{};
81 cudaArray_t arrayHandle =
nullptr;
82 cudaTextureObject_t textureHandle = 0;
89 CUDATexture3D(
const at::Tensor &tensor,
const std::string &addressModeX,
const std::string &addressModeY,
90 const std::string &addressModeZ);
94 [[nodiscard]]
unsigned long long Handle()
const;
120 : backingTensor(std::move(other.backingTensor)), arrayHandle(other.arrayHandle),
121 textureHandle(other.textureHandle) {
122 other.arrayHandle =
nullptr;
123 other.textureHandle = 0;
126 CUDATexture3D &operator=(CUDATexture3D &&other)
noexcept {
129 err = cudaDestroyTextureObject(textureHandle);
130 if (err != cudaSuccess) {
131 std::cerr <<
"cudaDestroyTextureObject failed: " << cudaGetErrorString(err) << std::endl << std::flush;
135 std::cout <<
"[C++] CUDA texture " <<
static_cast<uint64_t
>(textureHandle) <<
" destroyed." << std::endl <<
140 err = cudaFreeArray(arrayHandle);
141 if (err != cudaSuccess) {
142 std::cerr <<
"cudaFreeArray failed: " << cudaGetErrorString(err) << std::endl << std::flush;
146 std::cout <<
"[C++] CUDA array freed." << std::endl << std::flush;
149 backingTensor = std::move(other.backingTensor);
150 arrayHandle = other.arrayHandle;
151 textureHandle = other.textureHandle;
152 other.arrayHandle =
nullptr;
153 other.textureHandle = 0;
159 std::cout <<
"[C++] CUDATexture3D destructing." << std::endl << std::flush;
165 at::Tensor backingTensor{};
166 cudaArray_t arrayHandle =
nullptr;
167 cudaTextureObject_t textureHandle = 0;
Definition CUDATexture.h:7
unsigned long long Handle() const
CUDATexture2D(const at::Tensor &tensor, const std::string &addressModeX, const std::string &addressModeY)
CUDATexture2D(const at::Tensor &tensor, Vec< TextureAddressMode, 2 > addressModes)
at::Tensor SizeTensor() const
void CleanUp() noexcept
Cleans up the underlying PyTorch tensor, CUDA texture and CUDA array.
Definition CUDATexture.h:87
CUDATexture3D(const at::Tensor &tensor, const std::string &addressModeX, const std::string &addressModeY, const std::string &addressModeZ)
CUDATexture3D(const at::Tensor &tensor, Vec< TextureAddressMode, 3 > addressModes)
void CleanUp() noexcept
Cleans up the underlying PyTorch tensor, CUDA texture and CUDA array.
unsigned long long Handle() const
at::Tensor SizeTensor() const
A simple vector class derived from std::array<T, N>, providing overrides for all useful operators.
Definition Vec.h:21
__host__ static __device__ constexpr Vec FromIntArrayRef(const at::IntArrayRef &v)
Construct a Vec from an at::IntArrayRef (this is the type of at::Tensor::sizes())
Definition Vec.h:82
__host__ __device__ constexpr Vec Flipped() const
Construct a Vec with the same elements, but in the reverse order.
Definition Vec.h:161
Definition GridSample3DCPU.cpp:6