Dala.ML.EMLX (dala v0.3.2)

Copy Markdown View Source

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

PlatformGPUJITBackend
iOS deviceMetal (:gpu)Disabled (W^X){EMLX.Backend, device: :gpu}
iOS simulatorMetal (:gpu)Enabled{EMLX.Backend, device: :gpu}
OtherN/AN/ANx.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

available?()

@spec available?() :: boolean()

Checks if the EMLX hex package is available at runtime.

default_device()

@spec default_device() :: atom()

Returns the default device for the current platform.

ios_device?()

@spec ios_device?() :: boolean()

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

ios_simulator?()

@spec ios_simulator?() :: boolean()

Returns true if running in iOS Simulator.

platform_config()

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

Returns the platform-specific configuration map.

setup()

@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.