ExTorch.NN.Introspect
(extorch v0.2.0)
Copy Markdown
Introspect the structure of TorchScript (JIT) models.
This module provides functions to extract model architecture information
from loaded .pt models, including the computation graph, parameter shapes,
submodule structure, and available methods.
Example
model = ExTorch.JIT.load("resnet18.pt")
schema = ExTorch.NN.Introspect.schema(model)
IO.inspect(schema.submodules, label: "Submodules")
Summary
Functions
Get the JIT computation graph IR as a string.
Extract a structured schema from a JIT model.
Generate Elixir source code for an ExTorch.NN.Module DSL definition
that mirrors the structure of a loaded JIT model.
Functions
@spec graph(ExTorch.JIT.Model.t()) :: String.t()
Get the JIT computation graph IR as a string.
Returns the TorchScript IR for the model's forward method,
showing the operations and data flow.
@spec schema(ExTorch.JIT.Model.t()) :: ExTorch.NN.Introspect.Schema.t()
Extract a structured schema from a JIT model.
Returns a %ExTorch.NN.Introspect.Schema{} with parameter info,
submodule info, and method names.
@spec to_elixir(ExTorch.JIT.Model.t(), String.t()) :: String.t()
Generate Elixir source code for an ExTorch.NN.Module DSL definition
that mirrors the structure of a loaded JIT model.
Arguments
model- A loaded JIT model.module_name- The name for the generated Elixir module (default:"MyModel").
Returns
A string containing Elixir source code.