allocate.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 <memory>
  16. #include <new>
  17. #include <numeric>
  18. #include <string>
  19. #include <vector>
  20. #include "ultra_infer/utils/utils.h"
  21. namespace ultra_infer {
  22. class ULTRAINFER_DECL FDHostAllocator {
  23. public:
  24. bool operator()(void **ptr, size_t size) const;
  25. };
  26. class ULTRAINFER_DECL FDHostFree {
  27. public:
  28. void operator()(void *ptr) const;
  29. };
  30. #ifdef WITH_GPU
  31. class ULTRAINFER_DECL FDDeviceAllocator {
  32. public:
  33. bool operator()(void **ptr, size_t size) const;
  34. };
  35. class ULTRAINFER_DECL FDDeviceFree {
  36. public:
  37. void operator()(void *ptr) const;
  38. };
  39. class ULTRAINFER_DECL FDDeviceHostAllocator {
  40. public:
  41. bool operator()(void **ptr, size_t size) const;
  42. };
  43. class ULTRAINFER_DECL FDDeviceHostFree {
  44. public:
  45. void operator()(void *ptr) const;
  46. };
  47. #endif
  48. } // namespace ultra_infer