def max_allocated

bendtorch-core@0.1.0.0 · src/autograd/loss.bend:149

import bendtorch-core@0.1.0.0/src/autograd/loss.bend as Loss
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/storage/main.bend as Storage
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/elementwise.bend as Elementwise

149def max_allocated(input: Core.Dynamic, +target: Shape.Shape, +columns: Nat,
150  result: Result<&2, &1, Core.Error, Core.Tensor<target>>) -> Core.Dynamic & Result<&2, &1, Core.Error, Core.Dynamic>:
151  match result:
152    case Fail{error}:
153      (input, Fail{error})
154    case Done{Core.TTensor{storage, exact}}:
155      match storage:
156        case Storage.Empty{}:
157          (input, Done{Core.Packed{target, Core.TTensor{Storage.Empty{}, exact}}})
158        case Storage.Owned{+depth, +length, array, balanced, valid}:
159          max_rows(target, columns, depth, length, valid, exact, Elementwise.take(input))

Uses (11)

Used by (1)