cuda_utils.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include <cstdint>
  16. #include <cuda_runtime.h>
  17. #include <vector>
  18. #ifndef CUDA_CHECK
  19. #define CUDA_CHECK(callstr) \
  20. { \
  21. cudaError_t error_code = callstr; \
  22. if (error_code != cudaSuccess) { \
  23. std::cerr << "CUDA error " << error_code << " at " << __FILE__ << ":"; \
  24. std::cerr << __LINE__; \
  25. assert(0); \
  26. } \
  27. }
  28. #endif // CUDA_CHECK
  29. namespace ultra_infer {
  30. namespace vision {
  31. namespace utils {
  32. void CudaYoloPreprocess(uint8_t *src, int src_width, int src_height, float *dst,
  33. int dst_width, int dst_height,
  34. const std::vector<float> padding_value,
  35. cudaStream_t stream);
  36. } // namespace utils
  37. } // namespace vision
  38. } // namespace ultra_infer