~/bend-docscommunity

src/autograd/sum_dims.bend checks

raw source on the hub · import bendtorch-core@0.1.0.0/src/autograd/sum_dims.bend as Sum_dims

6 imports
import Base
import ../shape/core.bend as Shape
import ../tensor/core.bend as Core
import ../tensor/layout.bend as Layout
import ../tensor/transforms.bend as Transforms
import ./reduce.bend as Reduce

Types

type Error source · line 21 · raw

Data

type Plan source · line 26 · raw

Data

The kept shape, built with Shape.construct, and the dropped dimensions.

Definitions

def reduces source · line 30 · raw

@+axes:List<&2, U32> -> @+axis:U32 -> Bool

Whether the sum reduces axis axis: every axis for an empty list.

def kept_from source · line 38 · raw

@+axes:List<&2, U32> -> @dimensions:List<&2, U32> -> @+axis:U32 -> List<&2, U32>

The dimensions from axis axis on, each reduced one set to 1.

def kept_dimensions source · line 45 · raw

@+axes:List<&2, U32> -> @dimensions:List<&2, U32> -> List<&2, U32>

def dropped_next source · line 48 · raw

@reduced:Bool -> @extent:U32 -> @rest:List<&2, U32> -> List<&2, U32>

def dropped_from source · line 56 · raw

@+axes:List<&2, U32> -> @dimensions:List<&2, U32> -> @+axis:U32 -> List<&2, U32>

The dimensions from axis axis on, without the reduced ones.

def dropped_dimensions source · line 63 · raw

@+axes:List<&2, U32> -> @dimensions:List<&2, U32> -> List<&2, U32>

def limit source · line 68 · raw

@dimensions:List<&2, U32> -> U32

How many axes an input of these dimensions has for PyTorch's check: its rank, and 1 for a rank-0 input.

def refused source · line 77 · raw

@bounded:Bool -> @unique:Bool -> Maybe<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/layout.Error>

PyTorch's refusal of the axes, permute's checks in permute's order: an axis at or past the limit, then an axis listed twice.

def refusal source · line 86 · raw

@+axes:List<&2, U32> -> @+limit:U32 -> Maybe<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/layout.Error>

def plan_built source · line 89 · raw

@-kept:List<&2, U32> -> @+dropped:List<&2, U32> -> @built:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.ConstructResult<kept> -> Result<&2, &2, Error, Plan>

def plan_checked source · line 96 · raw

@+axes:List<&2, U32> -> @+dimensions:List<&2, U32> -> @checked:Maybe<&2, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/layout.Error> -> Result<&2, &2, Error, Plan>

def plan source · line 105 · raw

@+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> Result<&2, &2, Error, Plan>

The sum's plan for an input of this shape, or the refusal of its axes.

def transformed source · line 108 · raw

@result:Result<&2, &1, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/transforms.Error, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic> -> Result<&2, &1, Error, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic>

def shaped source · line 115 · raw

@+dropped:List<&2, U32> -> @keepdim:Bool -> @output:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic -> Result<&2, &1, Error, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic>

def squeezed source · line 122 · raw

@+dropped:List<&2, U32> -> @keepdim:Bool -> @result:Result<&2, &1, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce.Error, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic> -> Result<&2, &1, Error, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic>

def summed source · line 130 · raw

@+dropped:List<&2, U32> -> @keepdim:Bool -> @pair:Pair(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic, Result<&2, &1, 0x1689e5deb278c16abd3bd45eac101ef3/src/autograd/reduce.Error, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic>) -> Pair(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic, Result<&2, &1, Error, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic>)

def sum_planned source · line 137 · raw

@input:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic -> @plan:Plan -> @keepdim:Bool -> Pair(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic, Result<&2, &1, Error, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic>)

The sum of a planned input: reduce_to onto the kept shape, then, without keepdim, the reshape to the dropped dimensions. The input owner comes back.

def sum_checked source · line 141 · raw

@input:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic -> @keepdim:Bool -> @planned:Result<&2, &2, Error, Plan> -> Pair(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic, Result<&2, &1, Error, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic>)

def sum_dims source · line 151 · raw

@input:0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic -> @+axes:List<&2, U32> -> @keepdim:Bool -> Pair(0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic, Result<&2, &1, Error, 0x1689e5deb278c16abd3bd45eac101ef3/src/tensor/core.Dynamic>)

PyTorch's input.sum(dim=axes, keepdim=keepdim). The input owner always comes back unchanged next to the result.

def error_code source · line 155 · raw

@error:Error -> U32