TorchLean API

NN.IR.Operator

Graph operators #

An operation such as .softmax 1 has a constructor, .softmax, and a static attribute: axis 1. OpKind keeps both. OpTag keeps just the constructor, so code that needs an operation's name or parent count can ask for it without inventing an axis, shape, or convolution configuration.

Tensor parameters stay in the graph's external payload store. For example, .linear has no static attributes here, but its weight and bias still come from that store. The parent count describes dataflow: a linear node has one parent for its input tensor.

NN.IR.Graph adds node identities, dependency edges, and declared output shapes. The fixed torchlean.ir.v1 spelling of each constructor is defined separately in NN.Runtime.PyTorch.Wire.

structure NN.IR.HardMask :

A row-major Boolean mask carried by an IR operation.

The payload records its logical tensor shape separately from the flat array so graph validation can reject malformed serialized or programmatically constructed masks before evaluation. true means that the corresponding entry is allowed.

Instances For
    @[instance_reducible]
    def NN.IR.instDecidableEqHardMask.decEq (x✝ x✝¹ : HardMask) :
    Decidable (x✝ = x✝¹)
    Instances For

      Per-axis geometry for pooling and convolution operators.

      All three tensors describe the same spatial suffix of the input tensor. Keeping the geometry in one record prevents frontends from silently imposing a common stride or padding on every axis.

      Instances For
        @[instance_reducible]
        Instances For

          Shape metadata for an arbitrary-dimensional convolution.

          Axes before channelAxis are preserved and mapped independently. The channel axis is replaced by outChannels; every following axis is spatial and is governed by window.

          Instances For
            @[instance_reducible]
            def NN.IR.instDecidableEqConvConfig.decEq (x✝ x✝¹ : ConvConfig) :
            Decidable (x✝ = x✝¹)
            Instances For
              inductive NN.IR.OpKind :

              Operation kinds in an op-tagged computation graph.

              DecidableEq is derived (and therefore == is available) so passes can compare operation tags including their geometry payloads; the tensor-valued fields compare by row-major data.

              Instances For
                @[instance_reducible]
                @[instance_reducible]
                def NN.IR.instDecidableEqOpKind.decEq (x✝ x✝¹ : OpKind) :
                Decidable (x✝ = x✝¹)
                Instances For

                  Permitted parent-count interval for an IR operation.

                  • min :

                    Minimum number of parents required by the operation.

                  • max? : Option

                    Maximum number of parents, or none when no finite upper bound is imposed.

                  Instances For
                    Instances For
                      @[instance_reducible]

                      Structural metadata shared by all instances of an IR operation kind.

                      • tag : String

                        Short tag used in diagnostics; artifact codecs define their own spelling.

                      • arity : ParentArity

                        Permitted number of parent nodes.

                      Instances For
                        def NN.IR.instDecidableEqOpMetadata.decEq (x✝ x✝¹ : OpMetadata) :
                        Decidable (x✝ = x✝¹)
                        Instances For
                          @[instance_reducible]
                          inductive NN.IR.OpTag :

                          Constructor identity of an NN.IR.OpKind, with the payload forgotten.

                          Instances For
                            @[instance_reducible]
                            @[instance_reducible]
                            @[instance_reducible]

                            Every semantic operator identity, in declaration order.

                            Instances For
                              theorem NN.IR.OpTag.mem_all (tag : OpTag) :
                              tag all

                              Every operator identity occurs in the enumeration.

                              Construct an operation when its tag supplies all the static information.

                              For example, .relu becomes some .relu, while .softmax returns none because its axis is still missing. Tensor parameters such as linear weights are read separately from the payload store.

                              Instances For

                                Whether constructing the operation needs an axis, shape, or other static attributes.

                                Instances For

                                  Structural metadata shared by every instance of an operation.

                                  Parameters such as linear weights live outside the parent edges, so linear has arity one.

                                  Instances For

                                    Forget the static attributes of an operation.

                                    Instances For

                                      Structural metadata, obtained from the operation's constructor identity.

                                      Instances For

                                        Forgetting attributes and reconstructing an attribute-free operation preserves it.

                                        The minimum number of parent nodes expected by an OpKind.

                                        Instances For

                                          An optional maximum number of parent nodes expected by an OpKind.

                                          For concat, the verifier permits an arbitrary number of inputs (at least 2), so this returns none.

                                          Instances For

                                            A short tag for error messages and debugging output.

                                            Instances For

                                              Human-facing operation description including operation-local parameters.

                                              tag is short and stable for grouping/log filtering. describe is for diagnostics: it prints axes, shapes, seeds, and convolution/pooling metadata so malformed graph dumps are useful without cross-referencing the original builder.

                                              Instances For