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()
Summary
Functions
Checks if the EMLX hex package is available at runtime.
Returns the default device for the current platform.
Returns true if running on a real iOS device (not simulator).
Returns true if running in iOS Simulator.
Returns the platform-specific configuration map.
Configures EMLX for the current platform.
Functions
@spec available?() :: boolean()
Checks if the EMLX hex package is available at runtime.
@spec default_device() :: atom()
Returns the default device for the current platform.
@spec ios_device?() :: boolean()
Returns true if running on a real iOS device (not simulator).
@spec ios_simulator?() :: boolean()
Returns true if running in iOS Simulator.
Returns the platform-specific configuration map.
@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.