Skip to content

Instantly share code, notes, and snippets.

@meisa233
Created July 25, 2024 06:45
Show Gist options
  • Save meisa233/f19af464185019a72bfd57f064267b78 to your computer and use it in GitHub Desktop.
Save meisa233/f19af464185019a72bfd57f064267b78 to your computer and use it in GitHub Desktop.
  1. comment #include <THC/THC.h>
    replace THCudaCheck with AT_CUDA_CHECK
    add #include <ATen/cuda/CUDAContext.h>
  2. replace THCCeilDiv with at::ceil_div
    add #include <ATen/ceil_div.h>
  3. Delete THCudaMalloc
    add #include <ATen/cuda/ThrustAllocator.h>
  //THCudaCheck(THCudaMalloc(state, (void**) &mask_dev,
  //                      boxes_num * col_blocks * sizeof(unsigned long long)));

  //mask_dev = (unsigned long long*) THCudaMalloc(state, boxes_num * col_blocks * sizeof(unsigned long long));
  
  ↓
mask_dev = (unsigned long long*) c10::cuda::CUDACachingAllocator::raw_alloc(boxes_num * col_blocks * sizeof(unsigned long long));
  1. Delete THCudaFree
  //THCState *state = at::globalContext().lazyInitCUDA(); 
  //THCudaFree(state, mask_dev);
  
  ↓
  c10::cuda::CUDACachingAllocator::raw_delete(mask_dev);
  1. Redefine AT_CHECK
    add these lines in the top of the file(*.cu,*.cpp,*.cuh)
#ifndef AT_CHECK
#define AT_CHECK TORCH_CHECK
#endif
  1. replace <THC/THCDeviceUtils.cuh> with <ATen/cuda/DeviceUtils.cuh>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment