-
Notifications
You must be signed in to change notification settings - Fork 209
feat: prune tensor expr inspect results #1272
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
Conversation
nx/lib/nx/defn/expr.ex
Outdated
|
||
true -> | ||
parameters | ||
end |
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.
Currently this prints:
Nx.default_backend(Nx.Defn.Expr)
param_tensor = &Nx.Defn.Expr.parameter(Nx.Defn.Expr.tensor(&1), &2)
Enum.reduce(1..50, param_tensor.(0, 0), &Nx.add(&2, param_tensor.(&1, &1))) |> IO.inspect(limit: 10); nil
#Nx.Tensor<
s64
Nx.Defn.Expr
parameter a:0 s64
parameter b:1 s64
parameter d:2 s64
parameter f:3 s64
parameter h:4 s64
parameter j:5 s64
parameter l:6 s64
parameter n:7 s64
parameter p:8 s64
...
parameter dv:50 s64
...
de = add dc, dd s64
dg = add de, df s64
di = add dg, dh s64
dk = add di, dj s64
dm = add dk, dl s64
do = add dm, dn s64
dq = add do, dp s64
ds = add dq, dr s64
du = add ds, dt s64
dw = add du, dv s64
>
nx/lib/nx/defn/expr.ex
Outdated
(len = length(parameters)) > opts.limit -> | ||
[h | t] = parameters | ||
[h, {"...", ""} | Enum.drop(t, len - opts.limit)] |
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.
(len = length(parameters)) > opts.limit -> | |
[h | t] = parameters | |
[h, {"...", ""} | Enum.drop(t, len - opts.limit)] | |
length(parameters) > opts.limit -> | |
[h | t] = parameters | |
[h, {"...", ""} | Enum.take(t, -(opts.limit - 1))] |
@polvalente sorry, I pushed something but I messed up. |
@polvalente it shuold be good now. I used your idea of appending/prepending to the parameters and using the limit as a flag of when to do that once, so we don't need to do a later check. We just need tests and we are good. :) |
Awesome! I'll work on testing this :) |
Nx.Defn.Expr | ||
... \s | ||
>\ | ||
""" |
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.
@josevalim tests are kinda verbose, but I wanted to cover most edge cases
Adds pruning of in-between expressions so that we
it's easier to analyze the overall behavior of a Nx.Defn.Expr