elixir-nx / nx

Multi-dimensional arrays (tensors) and numerical definitions for Elixir
2.66k stars 193 forks source link

Upgrade NIF EXLA #1509

Closed samuelmanzanera closed 4 months ago

samuelmanzanera commented 5 months ago

Hello

I was trying to upgrade NX & EXLA through a hot upgrade process, however, the NIF is not supporting upgrade capability

ERL_NIF_INIT(Elixir.EXLA.NIF, exla_funcs, &load, NULL, NULL, NULL);

While TorchX supports it,

ERL_NIF_INIT(Elixir.Torchx.NIF, nif_functions, load, NULL, upgrade, NULL)

// ...
int upgrade(ErlNifEnv *env, void **priv_data, void **old_priv_data, ERL_NIF_TERM load_info) {
  // Silence "unused var" warnings.
  (void)(env);
  (void)(priv_data);
  (void)(old_priv_data);
  (void)(load_info);

  return 0;
}

Is there any reason for this choice ? Because in order to support hot upgrades of NX & Backend, then I have to rely on TorchX

josevalim commented 5 months ago

Please send a PR adding a similar callback. Thank you.