TorchLean API

NN.Runtime.PyTorch.Wire

Graph wire format #

NN.IR.OpTag identifies semantic operators. This module assigns each identity its fixed spelling in torchlean.ir.v2: for example, .mulElem is written as "mul_elem". Keeping this table separate from diagnostic names lets us improve an error message while keeping existing graphs readable. Exporters and importers use the same table.

The tag round trip is proved for every constructor. Static attributes are parsed separately; parse? constructs only operations that need none. Tuple projections and supported container nodes belong to the external value graph, not the tensor graph's semantic operator vocabulary.

Pointwise operators are spelled by operator rather than by their shared constructor: "div", "pow", "neg", "rsqrt", "erf", "gelu" and "clamp_min". GELU writes PyTorch's "approximate" string, and a rounded division writes its "rounding_mode"; true division has no such field. The family spelling "pointwise" names the constructor in diagnostics and is not an artifact kind.

Format marker written to the root format field.

Instances For

    Projection of one component out of a tuple-valued FX node.

    Instances For

      Container-valued nn.MultiheadAttention call kept in the value graph.

      Instances For

        Fixed constructor spelling in the torchlean.ir.v2 artifact.

        Instances For

          Parse a constructor spelling into its semantic identity.

          Instances For

            Parse an attribute-free operation; attributed operators need their separate fields.

            Instances For

              JSON or Python "kind": "<wire>" field for an operator identity.

              Instances For

                JSON or Python object holding only the kind field.

                Instances For

                  The wire string as a quoted JSON or Python literal.

                  Instances For

                    Python set expression of quoted wire strings. Empty input uses set(), not a dictionary.

                    Instances For

                      Fixed wire kind of a pointwise operator; its attribute is a separate field.

                      Instances For

                        Attribute field of gelu: PyTorch's approximate argument.

                        Instances For

                          Attribute field of a rounded div: PyTorch's rounding_mode argument.

                          Instances For

                            Name of the attribute field written with a pointwise kind, if that kind has one.

                            Instances For

                              Value of a pointwise operator's attribute field, using PyTorch's strings.

                              Instances For

                                Parse a pointwise operator from its kind and the value of its attribute field.

                                Instances For

                                  JSON or Python object holding a pointwise operator's kind and attribute fields.

                                  Instances For

                                    No pointwise kind collides with an ordinary constructor spelling.

                                    Every pointwise operator parses back from its kind and attribute: the codec is complete and collision free.

                                    Every tag parses back to its identity: the codec is complete and collision free.

                                    Serializing and parsing an operation preserves its identity, regardless of its attributes.

                                    The attribute-free round trip reconstructs the original operation.