-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add EXLA.to_mlir_module/2 #1497
Changes from all commits
765f657
de3e5a7
a9eecd9
bbef0a2
9ba0721
59cd78f
6e12151
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,11 @@ defmodule EXLA.MLIR.Module do | |
* `:use_spmd` - enables Single-Program Multiple-Data partioning. | ||
This is set to true if `:num_partitions` is more than one, otherwise is `false`. | ||
|
||
* `:module_compilation` - either `:to_mlir` or `:to_pjrt`. The default is `:to_pjrt`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @josevalim not sure about the option naming here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is private, so it is fine! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. We should return the string only, not the module struct. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The public-facing function is now returning the binary directly |
||
|
||
* `:to_pjrt` - the `EXLA.Executable` `:ref` field will hold the reference to a PjRt executable. | ||
* `:to_mlir` - the `EXLA.Executable` `:ref` field will hold the reference to an MLIR module. | ||
|
||
Currently those options do not have an effect as they related to running the | ||
same compiled executable on multiple replicas. | ||
|
||
|
@@ -102,16 +107,22 @@ defmodule EXLA.MLIR.Module do | |
# module |> as_string() |> IO.puts() | ||
|
||
ref = | ||
EXLA.NIF.mlir_compile( | ||
client.ref, | ||
module.ref, | ||
Enum.map(argument_typespecs, &EXLA.Typespec.nif_encode/1), | ||
num_replicas, | ||
num_partitions, | ||
use_spmd, | ||
device_id | ||
) | ||
|> unwrap!() | ||
case Keyword.get(options, :module_compilation, :to_pjrt) do | ||
:to_mlir -> | ||
module.ref | ||
|
||
:to_pjrt -> | ||
EXLA.NIF.mlir_compile( | ||
client.ref, | ||
module.ref, | ||
Enum.map(argument_typespecs, &EXLA.Typespec.nif_encode/1), | ||
num_replicas, | ||
num_partitions, | ||
use_spmd, | ||
device_id | ||
) | ||
|> unwrap!() | ||
end | ||
|
||
%Executable{ | ||
client: client, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gah, this is relying on internals of another module but I can't think of anything better for now, so ship it.