# extorch v0.3.0 - Table of Contents

Production ML model serving on the BEAM. Load TorchScript models, define neural networks with an Elixir DSL, and monitor serving performance with telemetry.

## Pages

- Guides
  - [Getting Started](getting-started.md)
  - [Serving Models](serving-models.md)
  - [Neural Network DSL](neural-network-dsl.md)
  - [Observability](observability.md)

## Modules

- General API
  - [ExTorch](ExTorch.md): The ``ExTorch`` namespace contains data structures for multi-dimensional tensors and mathematical operations over these are defined.
Additionally, it provides many utilities for efficient serializing of Tensors and arbitrary types, and other useful utilities.
  - [ExTorch.Tensor](ExTorch.Tensor.md): An ``ExTorch.Tensor`` is a multi-dimensional matrix containing elements of a single data type.

- JIT Model Serving
  - [ExTorch.JIT](ExTorch.JIT.md): TorchScript model loading, inference, and management.
  - [ExTorch.JIT.Model](ExTorch.JIT.Model.md): Represents a loaded TorchScript model.
  - [ExTorch.JIT.Server](ExTorch.JIT.Server.md): A GenServer that wraps a loaded TorchScript model for concurrent serving.

- Neural Network
  - [ExTorch.NN](ExTorch.NN.md): Neural network layer creation and operations.
  - [ExTorch.NN.Introspect](ExTorch.NN.Introspect.md): Introspect the structure of TorchScript (JIT) models.
  - [ExTorch.NN.Introspect.Schema](ExTorch.NN.Introspect.Schema.md): Structured representation of a JIT model's architecture.

  - [ExTorch.NN.JITBackedModel](ExTorch.NN.JITBackedModel.md): A model instance backed by a loaded TorchScript (.pt) file.
  - [ExTorch.NN.Layer](ExTorch.NN.Layer.md): Represents an instantiated neural network layer (nn.Module).
  - [ExTorch.NN.Module](ExTorch.NN.Module.md): DSL for defining neural network modules in Elixir.

- NN Layers
  - [ExTorch.NN.AdaptiveAvgPool1d](ExTorch.NN.AdaptiveAvgPool1d.md): 1D adaptive average pooling.
  - [ExTorch.NN.AdaptiveAvgPool2d](ExTorch.NN.AdaptiveAvgPool2d.md): 2D adaptive average pooling.
  - [ExTorch.NN.AvgPool1d](ExTorch.NN.AvgPool1d.md): 1D average pooling.
  - [ExTorch.NN.AvgPool2d](ExTorch.NN.AvgPool2d.md): 2D average pooling.
  - [ExTorch.NN.BatchNorm1d](ExTorch.NN.BatchNorm1d.md): 1D batch normalization layer.
  - [ExTorch.NN.BatchNorm2d](ExTorch.NN.BatchNorm2d.md): 2D batch normalization layer.
  - [ExTorch.NN.Conv1d](ExTorch.NN.Conv1d.md): 1D convolution layer.
  - [ExTorch.NN.Conv2d](ExTorch.NN.Conv2d.md): 2D convolution layer.
  - [ExTorch.NN.Conv3d](ExTorch.NN.Conv3d.md): 3D convolution layer.
  - [ExTorch.NN.ConvTranspose1d](ExTorch.NN.ConvTranspose1d.md): 1D transposed convolution.
  - [ExTorch.NN.ConvTranspose2d](ExTorch.NN.ConvTranspose2d.md): 2D transposed convolution.
  - [ExTorch.NN.Dropout](ExTorch.NN.Dropout.md): Dropout layer.
  - [ExTorch.NN.Embedding](ExTorch.NN.Embedding.md): Embedding layer.
  - [ExTorch.NN.Flatten](ExTorch.NN.Flatten.md): Flatten layer.
  - [ExTorch.NN.GRU](ExTorch.NN.GRU.md): GRU recurrent layer.
  - [ExTorch.NN.GroupNorm](ExTorch.NN.GroupNorm.md): Group normalization.
  - [ExTorch.NN.InstanceNorm1d](ExTorch.NN.InstanceNorm1d.md): 1D instance normalization.
  - [ExTorch.NN.InstanceNorm2d](ExTorch.NN.InstanceNorm2d.md): 2D instance normalization.
  - [ExTorch.NN.LSTM](ExTorch.NN.LSTM.md): LSTM recurrent layer.
  - [ExTorch.NN.LayerNorm](ExTorch.NN.LayerNorm.md): Layer normalization.
  - [ExTorch.NN.Linear](ExTorch.NN.Linear.md): Linear (fully connected) layer.
  - [ExTorch.NN.MaxPool1d](ExTorch.NN.MaxPool1d.md): 1D max pooling.
  - [ExTorch.NN.MaxPool2d](ExTorch.NN.MaxPool2d.md): 2D max pooling.
  - [ExTorch.NN.MultiheadAttention](ExTorch.NN.MultiheadAttention.md): Multi-head attention.
  - [ExTorch.NN.Unflatten](ExTorch.NN.Unflatten.md): Unflatten layer.

- NN Activations
  - [ExTorch.NN.ELU](ExTorch.NN.ELU.md): ELU activation.
  - [ExTorch.NN.GELU](ExTorch.NN.GELU.md): GELU activation.
  - [ExTorch.NN.LeakyReLU](ExTorch.NN.LeakyReLU.md): LeakyReLU activation.
  - [ExTorch.NN.LogSoftmax](ExTorch.NN.LogSoftmax.md): LogSoftmax.
  - [ExTorch.NN.Mish](ExTorch.NN.Mish.md): Mish activation.
  - [ExTorch.NN.PReLU](ExTorch.NN.PReLU.md): PReLU activation.
  - [ExTorch.NN.ReLU](ExTorch.NN.ReLU.md): ReLU activation.
  - [ExTorch.NN.SiLU](ExTorch.NN.SiLU.md): SiLU (Swish) activation.
  - [ExTorch.NN.Sigmoid](ExTorch.NN.Sigmoid.md): Sigmoid activation.
  - [ExTorch.NN.Softmax](ExTorch.NN.Softmax.md): Softmax activation.
  - [ExTorch.NN.Tanh](ExTorch.NN.Tanh.md): Tanh activation.

- Tensor Exchange
  - [ExTorch.Tensor.Blob](ExTorch.Tensor.Blob.md): Zero-copy tensor exchange between ExTorch and other tensor frameworks.
  - [ExTorch.Tensor.BlobView](ExTorch.Tensor.BlobView.md): A tensor view backed by foreign memory.

- AOTI Compiled Models
  - [ExTorch.AOTI](ExTorch.AOTI.md): Load and run inference on AOTInductor-compiled models (`.pt2` packages).
  - [ExTorch.AOTI.Model](ExTorch.AOTI.Model.md): Represents a loaded AOTI (.pt2) compiled model.
  - [ExTorch.AOTI.Server](ExTorch.AOTI.Server.md): A GenServer that wraps a loaded AOTI (.pt2) model for concurrent serving.

- Export Reader
  - [ExTorch.Export](ExTorch.Export.md): Read and introspect PyTorch ExportedProgram `.pt2` archives.
  - [ExTorch.Export.Model](ExTorch.Export.Model.md): A loaded ExportedProgram model ready for inference.
  - [ExTorch.Export.Server](ExTorch.Export.Server.md): A GenServer that wraps a loaded `torch.export.save` model for concurrent serving.

- Observability
  - [ExTorch.Metrics](ExTorch.Metrics.md): ETS-backed metrics collection for ExTorch model serving.
  - [ExTorch.Observer.Dashboard](ExTorch.Observer.Dashboard.md): A Phoenix LiveDashboard page for monitoring ExTorch model serving.

- Exchange types
  - [ExTorch.Complex](ExTorch.Complex.md): An ``ExTorch.Complex`` is a struct that represents a complex number with real and imaginary parts.
  - [ExTorch.Index](ExTorch.Index.md): An index is an object that can act as an accessor to a ``ExTorch.Tensor``.
ExTorch has five kinds of indices:

  - [ExTorch.Index.Slice](ExTorch.Index.Slice.md): Slice index definition.

  - [ExTorch.Tensor.Options](ExTorch.Tensor.Options.md): The ``ExTorch.Tensor.Options`` struct defines the creation parameters of a tensor.

  - [ExTorch.Utils.ListWrapper](ExTorch.Utils.ListWrapper.md): Struct used to represent a list with elements or lists of elements.

  - [ExTorch.Utils.PrintOptions](ExTorch.Utils.PrintOptions.md): Tensor printing options.

- Spec types
  - [ExTorch.DType](ExTorch.DType.md): A ``torch.dtype`` is an object that represents the data type of a ``torch.Tensor``.
ExTorch has twelve different data types:

  - [ExTorch.Device](ExTorch.Device.md): A torch.device is an object representing the device on which a torch.Tensor
is or will be allocated. The torch.device contains a device type ('cpu' or 'cuda')
and optional device ordinal for the device type. If the device ordinal is not
present, this object will always represent the current device for the device type,
even after ``torch.cuda.set_device()`` is called; e.g., a torch.Tensor constructed
with device 'cuda' is equivalent to 'cuda:X' where X is the result of
``torch.cuda.current_device()``.
  - [ExTorch.Layout](ExTorch.Layout.md): A ``torch.layout`` is an object that represents the memory layout of a ``torch.Tensor``.
Currently, we support ``torch.strided`` (dense Tensors) and have beta support for
``torch.sparse_coo`` (sparse COO Tensors).
  - [ExTorch.MemoryFormat](ExTorch.MemoryFormat.md): A ``torch.memory_format`` is an object representing the memory format on which
a ``torch.Tensor`` is or will be allocated.
  - [ExTorch.Scalar](ExTorch.Scalar.md): An `ExTorch.Scalar` is any singular value that can be stored in a `ExTorch.Tensor`.

- Protocols
  - [ExTorch.Protocol.DefaultStruct](ExTorch.Protocol.DefaultStruct.md)

- Macros
  - [ExTorch.DelegateWithDocs](ExTorch.DelegateWithDocs.md): Public API documentation for `DelegateWithDocs`. This module is based on
https://github.com/danielberkompas/delegate_with_docs

  - [ExTorch.ModuleMixin](ExTorch.ModuleMixin.md): Utilities used to define a module mixin that inherits documentation and specs.

  - [ExTorch.Native.BindingDeclaration](ExTorch.Native.BindingDeclaration.md): Conveniences for declaring native calls to a library in Rustler.
  - [ExTorch.Native.Macros](ExTorch.Native.Macros.md): General purpose macros to automatically generate binding declarations and calls
for both ExTorch callable functions and Rustler signature calls to the NIF library.

- Native API
  - [ExTorch.Native](ExTorch.Native.md): The `ExTorch.Native` module contains all NIF declarations to call libtorch in C++.

- Other utilities
  - [ExTorch.Utils](ExTorch.Utils.md)
  - [ExTorch.Utils.Types](ExTorch.Utils.Types.md): General type hierarchy comparison utils

- Exceptions
  - [ExTorch.DelegateWithDocs.Error](ExTorch.DelegateWithDocs.Error.md)

