File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -1820,3 +1820,8 @@ PHI_DEFINE_EXPORTED_double(accuracy_check_atol_bf16,
18201820PHI_DEFINE_EXPORTED_double (accuracy_check_rtol_bf16,
18211821 1e-3 ,
18221822 " It controls the rtol of accuracy_check op" );
1823+
1824+ PHI_DEFINE_EXPORTED_bool (
1825+ pinned_memory_as_cpu_backend,
1826+ false ,
1827+ " Whether use CPU backend, when tensor is pinned_memory." );
Original file line number Diff line number Diff line change @@ -14,16 +14,18 @@ limitations under the License. */
1414
1515#include " paddle/phi/core/compat/convert_utils.h"
1616
17+ #include " paddle/common/flags.h"
1718#include " paddle/phi/backends/gpu/gpu_info.h"
1819#include " paddle/phi/backends/xpu/xpu_info.h"
1920#include " paddle/phi/common/place.h"
2021#include " paddle/phi/core/compat/op_utils.h"
2122#include " paddle/phi/core/enforce.h"
22-
2323#ifdef PADDLE_WITH_CUSTOM_DEVICE
2424#include " paddle/phi/backends/device_manager.h"
2525#endif
2626
27+ COMMON_DECLARE_bool (pinned_memory_as_cpu_backend);
28+
2729namespace phi {
2830
2931Backend TransToPhiBackend (const phi::Place& place) {
@@ -33,8 +35,13 @@ Backend TransToPhiBackend(const phi::Place& place) {
3335 return Backend::GPU;
3436 case AllocationType::CPU:
3537 return Backend::CPU;
36- case AllocationType::GPUPINNED:
37- return Backend::CPU;
38+ case AllocationType::GPUPINNED: {
39+ if (FLAGS_pinned_memory_as_cpu_backend) {
40+ return Backend::CPU;
41+ } else {
42+ return Backend::GPU;
43+ }
44+ }
3845 case AllocationType::XPU:
3946 return Backend::XPU;
4047 case AllocationType::IPU:
You can’t perform that action at this time.
0 commit comments