TorchLean API

NN.MLTheory.CROWN.Operators.Slice

Slice / gather / split operator bounds #

This file provides IBP and affine transfer rules for a small subset of indexing-like operations:

Important limitation: this does not model tensor-valued index dtypes inside the differentiable graph (i.e. no PyTorch-style LongTensor indexing/gather/scatter driven by data tensors).

View a (.dim n .scalar) tensor as its underlying Fin n → Tensor α .scalar function.

Instances For
    def NN.MLTheory.CROWN.Operators.Slice.ibpSlice {α : Type} [Context α] (xB : FlatBox α) (start stop : ) :

    IBP for Slice: extract elements [start, stop) from a flattened vector. Slice is a linear operation, so bounds propagate exactly.

    Instances For

      IBP for Gather: index into a vector using integer indices. Given input x and indices i, output[j] = x[indices[j]]. Since indices are concrete, this is a permutation/selection.

      Instances For
        def NN.MLTheory.CROWN.Operators.Slice.ibpSplit {α : Type} [Context α] (xB : FlatBox α) (splitSizes : List ) :

        IBP for Split: split a vector into multiple parts. Returns a list of FlatBoxes, one for each split.

        Instances For
          def NN.MLTheory.CROWN.Operators.Slice.ibpSplit.buildSplits {α : Type} [Context α] (xB : FlatBox α) (flo fhi : Fin xB.dimSpec.Tensor α Spec.Shape.scalar) (remaining : List ) (offset : ) :
          Instances For
            def NN.MLTheory.CROWN.Operators.Slice.affSlice {α : Type} [Context α] {inDim outDim : } (start : ) (aff : AffineVec α inDim outDim) (sliceSize : ) :
            AffineVec α inDim sliceSize

            Affine bounds for Slice: extract subvector of affine form. If aff represents y = A·x + c, then slice just selects rows of A and c.

            Instances For
              def NN.MLTheory.CROWN.Operators.Slice.affGather {α : Type} [Context α] {inDim outDim : } (indices : List ) (aff : AffineVec α inDim outDim) :
              AffineVec α inDim indices.length

              Affine bounds for Gather: permute/select rows of affine form.

              Instances For
                def NN.MLTheory.CROWN.Operators.Slice.derivSlice {α : Type} [Context α] (dB : FlatBox α) (start stop : ) :

                Derivative bounds for Slice: derivatives just slice through.

                Instances For

                  Derivative bounds for Gather: derivatives follow the same indexing.

                  Instances For

                    Concatenate multiple FlatBoxes into one.

                    Instances For
                      theorem NN.MLTheory.CROWN.Operators.Slice.Theorems.ibp_slice_dim {α : Type} [Context α] (xB : FlatBox α) (start stop : ) (hvalid : start < stop stop xB.dim) :
                      (ibpSlice xB start stop).dim = stop - start

                      Slice output dimension matches stop - start for valid inputs.

                      theorem NN.MLTheory.CROWN.Operators.Slice.Theorems.ibp_slice_returns_box {α : Type} [Context α] (xB : FlatBox α) (start stop : ) :
                      ∃ (dim : ) (lo : Spec.Tensor α (Spec.Shape.dim dim Spec.Shape.scalar)) (hi : Spec.Tensor α (Spec.Shape.dim dim Spec.Shape.scalar)), ibpSlice xB start stop = { dim := dim, lo := lo, hi := hi }

                      Slice produces valid FlatBox structure.

                      theorem NN.MLTheory.CROWN.Operators.Slice.Theorems.ibp_gather_dim {α : Type} [Context α] (xB : FlatBox α) (indices : List ) :
                      (ibpGather xB indices).dim = indices.length

                      Gather output dimension equals indices length.

                      theorem NN.MLTheory.CROWN.Operators.Slice.Theorems.ibp_split_returns_list {α : Type} [Context α] (xB : FlatBox α) (splitSizes : List ) (box : FlatBox α) :
                      box ibpSplit xB splitSizes∃ (dim : ) (lo : Spec.Tensor α (Spec.Shape.dim dim Spec.Shape.scalar)) (hi : Spec.Tensor α (Spec.Shape.dim dim Spec.Shape.scalar)), box = { dim := dim, lo := lo, hi := hi }

                      Split produces list of valid FlatBoxes.

                      theorem NN.MLTheory.CROWN.Operators.Slice.Theorems.ibp_concat_dim {α : Type} [Context α] (boxes : List (FlatBox α)) :
                      (ibpConcat boxes).dim = List.foldl (fun (acc : ) (b : FlatBox α) => acc + b.dim) 0 boxes (ibpConcat boxes).dim = 0

                      Concat output dimension is sum of input dimensions.