Skip to content

Commit 3751716

Browse files
SigureMocodex
andcommitted
compat: fix pinned copy header usage
Replace the internal-only DenseTensor::memory_size() call in the compat mapped pinned helper with a header-visible byte count computation so downstream extensions that include compat headers keep compiling. Co-authored-by: Codex <codex@openai.com>
1 parent aaf06b7 commit 3751716

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

paddle/phi/api/include/compat/utils/mapped_pinned_tensor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ inline paddle::Tensor _PD_CopyTensorToPinnedPlace(
9595
auto src_dense = std::dynamic_pointer_cast<phi::DenseTensor>(src.impl());
9696
if (src_dense && src_dense->meta().is_contiguous() &&
9797
src_dense->meta().offset == 0) {
98-
auto bytes = src_dense->memory_size();
98+
auto bytes = static_cast<size_t>(src_dense->numel()) *
99+
phi::SizeOf(src_dense->dtype());
99100
auto holder = _PD_CreateMappedPinnedAllocation(bytes, pinned_place);
100101
if (bytes > 0) {
101102
std::memcpy(holder->ptr(), src_dense->data(), bytes);

0 commit comments

Comments
 (0)