Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
e6309acd
Unverified
Commit
e6309acd
authored
Nov 22, 2025
by
Jane (Yuan) Xu
Committed by
GitHub
Nov 22, 2025
Browse files
Simplify `from_blob` usage in `get_cuda_view_from_cpu_tensor` (#29027)
Signed-off-by:
Jane Xu
<
janeyx@meta.com
>
parent
988ee66b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
8 deletions
+3
-8
csrc/cuda_view.cu
csrc/cuda_view.cu
+3
-8
No files found.
csrc/cuda_view.cu
View file @
e6309acd
...
...
@@ -22,15 +22,10 @@ torch::Tensor get_cuda_view_from_cpu_tensor(torch::Tensor& cpu_tensor) {
auto
strides
=
cpu_tensor
.
strides
();
auto
options
=
cpu_tensor
.
options
().
device
(
torch
::
kCUDA
);
// from_blob signature: from_blob(void *data, IntArrayRef sizes, ..., Deleter,
// const TensorOptions &) Provide a no-op deleter. The CPU tensor holds the
// memory, so we don't free it here.
auto
deleter
=
[](
void
*
)
{
// no-op, since the memory is owned by the original CPU tensor
};
// use default no-op deleter, since the memory is owned by the original CPU
// tensor
torch
::
Tensor
cuda_tensor
=
torch
::
from_blob
(
device_ptr
,
sizes
,
strides
,
deleter
,
options
);
torch
::
from_blob
(
device_ptr
,
sizes
,
strides
,
options
);
TORCH_CHECK
(
cuda_tensor
.
device
().
is_cuda
(),
"Resulting tensor is not on CUDA device"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment