A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.pytorch.org/docs/stable/generated/torch.as_strided.html below:

torch.as_strided — PyTorch 2.8 documentation

Create a view of an existing torch.Tensor input with specified size, stride and storage_offset.

Warning

Prefer using other view functions, like torch.Tensor.view() or torch.Tensor.expand(), to setting a view’s strides manually with as_strided, as this function will throw an error on non-standard Pytorch backends (that do not have a concept of stride) and the result will depend on the current layout in memory. The constructed view must only refer to elements within the Tensor’s storage or a runtime error will be thrown. If the generated view is “overlapped” (with multiple indices referring to the same element in memory), the behavior of inplace operations on this view is undefined (and might not throw runtime errors).

>>> x = torch.randn(3, 3)
>>> x
tensor([[ 0.9039,  0.6291,  1.0795],
        [ 0.1586,  2.1939, -0.4900],
        [-0.1909, -0.7503,  1.9355]])
>>> t = torch.as_strided(x, (2, 2), (1, 2))
>>> t
tensor([[0.9039, 1.0795],
        [0.6291, 0.1586]])
>>> t = torch.as_strided(x, (2, 2), (1, 2), 1)
tensor([[0.6291, 0.1586],
        [1.0795, 2.1939]])

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4