# `Dala.ML.EMLX`
[🔗](https://github.com/manhvu/dala/blob/main/lib/dala/ml/emlx.ex#L1)

EMLX (Apple Silicon GPU) integration for Dala.

EMLX provides GPU-accelerated tensor operations via Apple's Metal framework.
This module handles zero-config setup: no NIF delegation needed, just
direct Application config and Nx backend selection.

## Platform Behavior

| Platform | GPU | JIT | Backend |
|----------|-----|-----|---------|
| iOS device | Metal (`:gpu`) | Disabled (W^X) | `{EMLX.Backend, device: :gpu}` |
| iOS simulator | Metal (`:gpu`) | Enabled | `{EMLX.Backend, device: :gpu}` |
| Other | N/A | N/A | `Nx.BinaryBackend` |

## Usage

    # At app startup — auto-configures everything:
    Dala.ML.setup()

    # Or configure EMLX directly:
    Dala.ML.EMLX.setup()

# `available?`

```elixir
@spec available?() :: boolean()
```

Checks if the EMLX hex package is available at runtime.

# `default_device`

```elixir
@spec default_device() :: atom()
```

Returns the default device for the current platform.

# `ios_device?`

```elixir
@spec ios_device?() :: boolean()
```

Returns `true` if running on a real iOS device (not simulator).

# `ios_simulator?`

```elixir
@spec ios_simulator?() :: boolean()
```

Returns `true` if running in iOS Simulator.

# `platform_config`

```elixir
@spec platform_config() :: %{jit_enabled: boolean(), device: atom()}
```

Returns the platform-specific configuration map.

# `setup`

```elixir
@spec setup() :: :ok
```

Configures EMLX for the current platform.

- On iOS: sets `{EMLX.Backend, device: :gpu}` as the Nx default backend.
  JIT is disabled on real devices (W^X policy) and enabled on simulator.
- On other platforms: falls back to `Nx.BinaryBackend`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
