As_strided
Source:R/gen-namespace-docs.R
, R/gen-namespace-examples.R
, R/gen-namespace.R
torch_as_strided.Rd
As_strided
as_strided(input, size, stride, storage_offset=0) -> Tensor
Create a view of an existing torch_Tensor
input
with specified
size
, stride
and storage_offset
.
Warning
More than one element of a created tensor may refer to a single memory location. As a result, in-place operations (especially ones that are vectorized) may result in incorrect behavior. If you need to write to the tensors, please clone them first.
Examples
if (torch_is_installed()) {
x = torch_randn(c(3, 3))
x
t = torch_as_strided(x, list(2, 2), list(1, 2))
t
t = torch_as_strided(x, list(2, 2), list(1, 2), 1)
t
}
#> torch_tensor
#> -1.1008 1.8645
#> -0.5921 1.5321
#> [ CPUFloatType{2,2} ]