NuTorch

Shape ops

Generated from the binaries by scripts/gen-ops-reference.ts — do not edit by hand. Every op also documents itself: torch <op> --help.

cat

concatenate tensors along —dim (default 0)

torch cat <t1>... (at least 2) [--dim <Int>]

reshape

reshape to the given shape (-1 infers one dim)

torch reshape <t1> <shape>

permute

permute dimensions

torch permute <t1> <dims>

transpose

swap two dimensions

torch transpose <t1> <dim0> <dim1>

t

transpose a 2-D tensor

torch t <t1>

squeeze

drop size-1 dims (all, or —dim)

torch squeeze <t1> [--dim <Int>]

unsqueeze

insert a size-1 dim

torch unsqueeze <t1> <dim>

flatten

flatten dims (—start_dim/—end_dim)

torch flatten <t1> [--start_dim <Int>] [--end_dim <Int>]

stack

stack tensors along a NEW —dim (default 0)

torch stack <t1>... (at least 2) [--dim <Int>]

split

split into chunks of split_size along —dim

torch split <t1> <split_size> [--dim <Int>]

chunk

split into N chunks along —dim

torch chunk <t1> <chunks> [--dim <Int>]

gather

gather values along —dim using an int64 index tensor

torch gather <t1> <t2> [--dim <Int>]

index_select

select rows/cols along —dim by an int64 index tensor

torch index_select <t1> <t2> [--dim <Int>]

masked_select

select by mask (numeric mask cast via != 0, a NuTorch-ism)

torch masked_select <t1> <t2>

where

cond ? x : y (numeric cond cast via != 0, a NuTorch-ism)

torch where <t1> <t2> <t3>

narrow

slice: length elements from start along dim

torch narrow <t1> <dim> <start> <length>

flip

reverse along the given dims

torch flip <t1> <dims>

roll

roll elements by shifts (optionally along —dims)

torch roll <t1> <shifts> [--dims <IntList>]

repeat

tile the tensor by repeats per dim

torch repeat <t1> <repeats>

repeat_interleave

repeat each element N times (optionally along —dim)

torch repeat_interleave <t1> <repeats> [--dim <Int>]

movedim

move a dim to a new position

torch movedim <t1> <source> <destination>

take_along_dim

gather along —dim with a broadcastable int64 index

torch take_along_dim <t1> <t2> [--dim <Int>]

scatter

non-inplace scatter: input, int64 index, src along —dim

torch scatter <t1> <t2> <t3> [--dim <Int>]