# This file is auto-generated by alef — DO NOT EDIT.
# alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
# To regenerate: alef generate
# To verify freshness: alef verify --exit-code
# Issues & docs: https://github.com/kreuzberg-dev/alef
defmodule Kreuzberg.AccelerationConfig do
  @moduledoc """
  Hardware acceleration configuration for ONNX Runtime models.

  Controls which execution provider (CPU, CoreML, CUDA, TensorRT) is used
  for inference in layout detection and embedding generation.

  # Example

  ```rust
  use kreuzberg::AccelerationConfig;

  // Auto-select: CoreML on macOS, CUDA on Linux, CPU elsewhere
  let config = AccelerationConfig::default();

  // Force CPU only
  let config = AccelerationConfig {
      provider: kreuzberg::ExecutionProviderType::Cpu,
      ..Default::default()
  };
  ```
  """

  @typedoc "Hardware acceleration configuration for ONNX Runtime models."
  @type t :: %__MODULE__{
          provider: String.t() | nil,
          device_id: non_neg_integer()
        }

  defstruct provider: :auto,
            device_id: 0

  defimpl Jason.Encoder do
    @doc false
    def encode(value, opts) do
      value
      |> Map.from_struct()
      |> Enum.reject(fn {_k, v} -> v == nil end)
      |> Enum.into(%{})
      |> Jason.Encoder.encode(opts)
    end
  end
end
