Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Evision.Backend

livebooks/evision/backend.livemd

Evision.Backend

Mix.install([
  {:benchee, "~> 1.3"},
  {:nx, "~> 0.9"},
  {:exla, "~> 0.9"},
  {:torchx, "~> 0.9"},
  {:evision, "~> 0.2"},
  {:kino, "~> 0.14"}
])

各バックエンドでの加算

tensor = Nx.tensor([1, 2, 3], type: :f64, backend: Nx.BinaryBackend)
Nx.add(tensor, tensor)
tensor = Nx.tensor([1, 2, 3], type: :f64, backend: EXLA.Backend)
Nx.add(tensor, tensor)
tensor = Nx.tensor([1, 2, 3], type: :f64, backend: Torchx.Backend)
Nx.add(tensor, tensor)
tensor = Nx.tensor([1, 2, 3], type: :f64, backend: Evision.Backend)
Nx.add(tensor, tensor)

ベンチマーク

bench = fn backend ->
  tensor =
    {200, 200}
    |> Nx.iota(type: :f64, backend: backend)

  Nx.add(tensor, tensor)
end
bench.(Nx.BinaryBackend)
bench.(Evision.Backend)
Benchee.run(%{
  "binary" => fn -> bench.(Nx.BinaryBackend) end,
  "exla" => fn -> bench.(EXLA.Backend) end,
  "torchx" => fn -> bench.(Torchx.Backend) end,
  "evision" => fn -> bench.(Evision.Backend) end
})