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

Function ToVector

paddle/phi/kernels/funcs/tensor_to_string.h:34–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32
33template <typename T>
34static std::vector<T> ToVector(const T *x,
35 size_t n,
36 const phi::Place &place UNUSED) {
37#ifdef __NVCC__
38 if (place.GetType() == AllocationType::GPU) {
39 using CopyT = typename std::
40 conditional<std::is_same<T, bool>::value, uint8_t, T>::type;
41 std::vector<CopyT> cpu_x(n);
42 auto *dev_ctx =
43 static_cast<GPUContext *>(DeviceContextPool::Instance().Get(place));
44 memory_utils::Copy(
45 CPUPlace(), cpu_x.data(), place, x, n * sizeof(T), dev_ctx->stream());
46 dev_ctx->Wait();
47 return std::vector<T>(cpu_x.data(), cpu_x.data() + n);
48 }
49#endif
50 return std::vector<T>(x, x + n);
51}
52
53template <typename T>
54static std::vector<T> ToVector(const DenseTensor &src) {

Callers 3

FlattenToStringFunction · 0.85
ComputeRowImplFunction · 0.85
ComputeImplFunction · 0.85

Calls 11

InstanceFunction · 0.85
CopyFunction · 0.50
CPUPlaceClass · 0.50
GetTypeMethod · 0.45
GetMethod · 0.45
dataMethod · 0.45
streamMethod · 0.45
WaitMethod · 0.45
IsInitializedMethod · 0.45
numelMethod · 0.45
placeMethod · 0.45

Tested by

no test coverage detected