ml_switcheroo.core.latex ======================== .. py:module:: ml_switcheroo.core.latex .. autoapi-nested-parse:: LaTeX DSL Core Package. This package contains the semantic primitives for the Machine Intelligence Definition Language (MIDL). It defines the node structures mirroring the LaTeX macros (`\Attribute`, `\Op`, etc.) used to visualize neural network architectures. Submodules ---------- .. toctree:: :maxdepth: 1 /api/ml_switcheroo/core/latex/nodes/index /api/ml_switcheroo/core/latex/parser/index Classes ------- .. autoapisummary:: ml_switcheroo.core.latex.LatexNode ml_switcheroo.core.latex.ModelContainer ml_switcheroo.core.latex.MemoryNode ml_switcheroo.core.latex.InputNode ml_switcheroo.core.latex.ComputeNode ml_switcheroo.core.latex.StateOpNode ml_switcheroo.core.latex.ReturnNode Package Contents ---------------- .. py:class:: LatexNode Bases: :py:obj:`abc.ABC` Abstract base class for all MIDL nodes. Enforces a ``to_latex()`` method for serialization support. .. py:method:: to_latex() -> str :abstractmethod: Serializes the node object back into its LaTeX macro representation. :returns: Valid LaTeX code string. :rtype: str .. py:class:: ModelContainer Bases: :py:obj:`LatexNode` Root container representing the Model definition block. Maps to the ``DefModel`` environment. .. py:attribute:: name :type: str The model class name. .. py:attribute:: children :type: List[LatexNode] :value: [] List of body statements (Memory, Input, Ops, Return). .. py:method:: to_latex() -> str Render the full ``\begin{DefModel}...\end{DefModel}`` block. .. py:class:: MemoryNode Bases: :py:obj:`LatexNode` Represents stateful memory allocation (e.g., Weights/Layers). Maps to the ``\Attribute`` macro. Example:: \Attribute{conv}{Conv2d}{in=1, out=32, k=3} .. py:attribute:: node_id :type: str The unique identifier for the attribute. .. py:attribute:: op_type :type: str The operation type (e.g., 'Conv2d'). .. py:attribute:: config :type: Dict[str, str] Configuration parameters for the layer. .. py:method:: to_latex() -> str Render to ``\Attribute`` macro. .. py:class:: InputNode Bases: :py:obj:`LatexNode` Represents the model input definition. Maps to the ``\Input`` macro. Example:: \Input{x}{[B, 1, 28, 28]} .. py:attribute:: name :type: str Name of the input variable. .. py:attribute:: shape :type: str Shape descriptor string. .. py:method:: to_latex() -> str Render to ``\Input`` macro. .. py:class:: ComputeNode Bases: :py:obj:`LatexNode` Represents a stateless operation call. Maps to the ``\Op`` macro. Example:: \Op{s2}{Flatten}{s1, start=1}{[B, 21632]} .. py:attribute:: node_id :type: str The unique identifier to assign the result to. .. py:attribute:: op_type :type: str The operation type (e.g., 'Flatten'). .. py:attribute:: args :type: List[str] List of arguments passed to the operation. .. py:attribute:: shape :type: str Resulting shape descriptor. .. py:method:: to_latex() -> str Render to ``\Op`` macro. .. py:class:: StateOpNode Bases: :py:obj:`LatexNode` Represents a call to a stateful layer defined in Memory. Maps to the ``\StateOp`` macro. Example:: \StateOp{s1}{conv}{x}{[B, 32, 26, 26]} .. py:attribute:: node_id :type: str The unique identifier to assign the result to. .. py:attribute:: attribute_id :type: str The ID of the attribute being called. .. py:attribute:: args :type: List[str] List of arguments passed to the call. .. py:attribute:: shape :type: str Resulting shape descriptor. .. py:method:: to_latex() -> str Render to ``\StateOp`` macro. .. py:class:: ReturnNode Bases: :py:obj:`LatexNode` Represents the output return statement. Maps to the ``\Return`` macro. Example:: \Return{s3} .. py:attribute:: target_id :type: str The variable ID to return. .. py:method:: to_latex() -> str Render to ``\Return`` macro.