MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / TransDataLayout

Function TransDataLayout

paddle/phi/api/lib/data_transform.cc:72–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72inline phi::DenseTensor TransDataLayout(const phi::DenseTensor& tensor,
73 DataLayout layout) {
74 auto& pool = phi::DeviceContextPool::Instance();
75 VLOG(3) << "DataLayoutTransform src_layout: " << tensor.layout()
76 << " dst_layout: " << layout;
77 if (tensor.place().GetType() == phi::AllocationType::CPU) {
78 auto* dev_ctx = static_cast<phi::CPUContext*>(pool.Get(tensor.place()));
79 return phi::TransferLayout(*dev_ctx, tensor, layout);
80 } else {
81 PADDLE_THROW(common::errors::PreconditionNotMet(
82 "Unsupported data layout cast from CPU to GPU."));
83 }
84 return tensor;
85}
86
87template <typename Context>
88phi::DenseTensor CastDataType(const Context& dev_ctx,

Callers 2

TransformDataFunction · 0.70
TESTFunction · 0.50

Calls 6

InstanceFunction · 0.85
TransferLayoutFunction · 0.50
layoutMethod · 0.45
GetTypeMethod · 0.45
placeMethod · 0.45
GetMethod · 0.45

Tested by 1

TESTFunction · 0.40