NAME
PDL::Torch::Tensor - Opaque LibTorch tensor handle with operator overloading
SYNOPSIS
use PDL;
use PDL::Torch qw(pdl2tensor);
my $a = pdl2tensor(double([[1, 2], [3, 4]]));
my $b = pdl2tensor(double([[5, 6], [7, 8]]));
my $sum = ($a + $b)->sum()->pdl();
my $prod = ($a x $b)->pdl();
DESCRIPTION
PDL::Torch::Tensor wraps an opaque torch::Tensor handle managed by PDL::Torch XS, providing Perl operator overloading (+, -, *, /, x for matrix multiplication) and deterministic VRAM/RAM cleanup via DESTROY.
METHODS
pdl
Transfer the tensor to CPU (if needed) and return a PDL ndarray.
to( $device )
Return a new tensor moved to $device (e.g., 'cpu', 'cuda', 'cuda:0').
cpu
Shorthand for $tensor->to('cpu').
cuda
Shorthand for $tensor->to('cuda').
device
Return the tensor's current device string (e.g., 'cpu', 'cuda:0').
dtype
Return the tensor's LibTorch dtype name (e.g., 'float64', 'complex64').
dims
Return the tensor's shape as a list of dimension sizes.
add / sub / mul / div / matmul
Binary tensor operations (also bound to +, -, *, /, and x).
sum / mean
Reduction operations returning a scalar PDL::Torch::Tensor.
SEE ALSO
AUTHOR
C.J. Collier <cjac@google.com>
LICENSE
Licensed under the Apache License, Version 2.0.