Last week, we discussed the usage of Nx.Defn.jit/3 to JIT compile and run numerical definitions. Nx also supports ahead-of-time compilation using Nx.Defn.aot/3. In this post, we'll briefly look at how to use ahead-of-time compilation, and why you'd want to do it in the first place. Ahead-of-time compilation allows you to compile your numerical definitions into … Continue reading Nx Tip of the Week #8 – Using Nx.Defn.aot/3
Tag: nx-totw
Nx Tip of the Week #7 – Using Nx.Defn.jit
There are actually 2 ways in Nx to accelerate your numerical definitions: invoking calls to defn with a @defn_compiler attribute set, or calling Nx.Defn.jit/3. Let's take a look at these 2 methods in practice: defmodule JIT do import Nx.Defn @default_defn_compiler EXLA defn softmax(x) do max_val = Nx.reduce_max(x) Nx.exp(x - max_val) / Nx.sum(Nx.exp(x - max_val)) end … Continue reading Nx Tip of the Week #7 – Using Nx.Defn.jit
Nx Tip of the Week #2 – Tensor Operations for Elixir Programmers
In Elixir, it's common to manipulate data using the Enum module. Enum provides a set of library functions for working with types that implement the Enumerable protocol. The Enum module is a productive interface for manipulating lists, maps, sets, etc. However, learning how to think about tensor manipulation using Nx can be a bit difficult … Continue reading Nx Tip of the Week #2 – Tensor Operations for Elixir Programmers