Skip to content

Commit

Permalink
Make compatible with pytorch 1.11 and newer; bugfix (#418)
Browse files Browse the repository at this point in the history
* Bugfix: missing include common.h

Signed-off-by: Krishna Murthy <krrish94@gmail.com>

* Make compatible with pytorch 1.11 and newer -- THCudaCheck() deprecated

Signed-off-by: Krishna Murthy <krrish94@gmail.com>

---------

Signed-off-by: Krishna Murthy <krrish94@gmail.com>
  • Loading branch information
krrish94 authored Feb 8, 2023
1 parent 331ecdd commit c959dab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 6 additions & 8 deletions encoding/lib/gpu/lib_ssd.cu
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

#include <ATen/ATen.h>
#include <ATen/cuda/CUDAContext.h>
#include <THC/THCNumerics.cuh>
#include <THC/THC.h>

#include <cuda.h>

Expand Down Expand Up @@ -378,22 +376,22 @@ std::vector<at::Tensor> box_encoder(const int N_img,
printf("allocating %lu bytes for output labels\n", N_img*M*sizeof(long));
#endif
at::Tensor labels_out = at::empty({N_img * M}, labels_input.options());
THCudaCheck(cudaGetLastError());
C10_CUDA_CHECK(cudaGetLastError());

// copy default boxes to outputs
#ifdef DEBUG
printf("allocating %lu bytes for output bboxes\n", N_img*M*4*sizeof(float));
#endif
at::Tensor bbox_out = dbox.repeat({N_img, 1});
THCudaCheck(cudaGetLastError());
C10_CUDA_CHECK(cudaGetLastError());

// need to allocate some workspace
#ifdef DEBUG
printf("allocating %lu bytes for workspace\n", 8*M*N_img);
#endif
// at::Tensor workspace = at::CUDA(at::kByte).zeros({8 * M * N_img});
at::Tensor workspace = at::zeros({8 * M * N_img}, at::CUDA(at::kByte));
THCudaCheck(cudaGetLastError());
C10_CUDA_CHECK(cudaGetLastError());

// Encode the inputs
const int THREADS_PER_BLOCK = 256;
Expand All @@ -408,7 +406,7 @@ std::vector<at::Tensor> box_encoder(const int N_img,
(float4*)bbox_out.data_ptr<float>(),
labels_out.data_ptr<long>());

THCudaCheck(cudaGetLastError());
C10_CUDA_CHECK(cudaGetLastError());
return {bbox_out, labels_out};
}

Expand All @@ -435,7 +433,7 @@ at::Tensor calc_ious(const int N_img,
(float4*)boxes2.data_ptr<float>(),
ious.data_ptr<float>());

THCudaCheck(cudaGetLastError());
C10_CUDA_CHECK(cudaGetLastError());
return ious;
}

Expand Down Expand Up @@ -569,7 +567,7 @@ std::vector<at::Tensor> random_horiz_flip(
flip.data_ptr<float>(),
tmp_img.data_ptr<scalar_t>(),
nhwc);
THCudaCheck(cudaGetLastError());
C10_CUDA_CHECK(cudaGetLastError());
});

// copy tmp_img -> img
Expand Down
2 changes: 2 additions & 0 deletions encoding/lib/gpu/rectify_cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <ATen/cuda/detail/IndexUtils.cuh>
#include <ATen/cuda/detail/KernelUtils.h>

#include "common.h"


template <typename dest_t, typename src_t>
static inline dest_t safe_downcast(src_t v)
Expand Down

0 comments on commit c959dab

Please sign in to comment.