ez icon indicating copy to clipboard operation
ez copied to clipboard

zig linear algebra bindings for nx

Ez

Zig bindings for elixir-nx. You can use CPU-mode nx without having to install jvm, bazel, and python!

Seeking Contributors

I don't have very much bandwidth for this, so if you are interested in the intersection of elixir and fast computational processing, I'm looking for collaborators/contributors.

Instructions

clone elixir-nx (https://github.com/elixir-nx/nx) into a directory at the same level as ez. When Nx becomes hosted on hex.pm this will not be necessary in the future

Issues

Zigler seems to (as of 0.7.3) be having some trouble compiling and binding MacOS dynamic libraries. See this: https://github.com/ityonemo/zigler/issues/248

Examples

tensor1 = 
  |> Nx.tensor([[1.0, 2.0]], type: {:f, 32})
  |> Nx.backend_transfer(Ez.ZigSliceBackend)
  
tensor2 = 
  |> Nx.tensor([[3.0, 4.0]], type: {:f, 32})
  |> Nx.backend_transfer(Ez.ZigSliceBackend)

result = Nx.add(tensor1, tensor2)

Nx.to_binary(result) # <<4.0 :: 32-float-native, 6.0 :: 32-float-native>>

Installation

If available in Hex, the package can be installed by adding ez to your list of dependencies in mix.exs:

def deps do
  [
    {:ez, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/ez.