Skip to content
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

Add metadata to layers #535

Merged
merged 3 commits into from
Oct 10, 2023
Merged

Add metadata to layers #535

merged 3 commits into from
Oct 10, 2023

Conversation

seanmor5
Copy link
Contributor

@seanmor5 seanmor5 commented Oct 9, 2023

This attaches Axon specific metadata to layers in the form of the op_name. This allows backends and compilers to match specifically on these patterns if they're available and provide optimized versions of layers rather than depending on the lower-level Nx implementation.

@seanmor5
Copy link
Contributor Author

seanmor5 commented Oct 9, 2023

I think there may be an Nx bug that surfaces here. All of my "constant with other operations" tests fail with a function clause error on scope_ids_each:

         # 1
         #Nx.Tensor<
           f32[1][2][3]
           [
             [
               [0.0, 1.0, 2.0],
               [3.0, 4.0, 5.0]
             ]
           ]
         >
     
         # 2
         {%{#Reference<0.4002093073.794296321.209144> => :metadata}, %{}}
     
         # 3
         nil
     
     Attempted function clauses (showing 3 out of 3):
     
         defp scope_ids_each(%Nx.Tensor{data: %Nx.Defn.Expr{op: :constant}}, {ids, cond_ids}, _scope)
         defp scope_ids_each(%Nx.Tensor{data: %Nx.Defn.Expr{id: id, op: op} = expr} = t, {ids, cond_ids}, nil)
         defp scope_ids_each(%Nx.Tensor{data: %Nx.Defn.Expr{id: id}} = t, {ids, cond_ids}, scope)

cc @josevalim

lib/axon/compiler.ex Outdated Show resolved Hide resolved
lib/axon/compiler.ex Outdated Show resolved Hide resolved
lib/axon/compiler.ex Outdated Show resolved Hide resolved
@josevalim
Copy link
Contributor

@seanmor5 it should be good now :)

@josevalim
Copy link
Contributor

FWIW, the failing tests should be fixed by using Nx.all_close or similar. :)

@seanmor5 seanmor5 merged commit 235a030 into main Oct 10, 2023
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants