-
Notifications
You must be signed in to change notification settings - Fork 33
mem effects #1666
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
mem effects #1666
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1666 +/- ##
==========================================
- Coverage 68.82% 67.75% -1.07%
==========================================
Files 103 108 +5
Lines 11596 11783 +187
==========================================
+ Hits 7981 7984 +3
- Misses 3615 3799 +184 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/TracedUtils.jl
Outdated
| if attr isa Nothing | ||
| return false | ||
| end | ||
| for i in 1:length(attr) |
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.
I'm on the phone, but I think this entire for loop until the final return can be written as
any(at -> String(at) == "write", attr)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.
problem is that attr doesn't define an iterator
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.
It has indices but isn't iterable? That sounds unfortunate, the basic iteration interface is a single function: https://docs.julialang.org/en/v1/manual/interfaces/#man-interface-iteration
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.
yeah I mean ironically the definition of that is in this repo (attribute.jl)
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.
I can push this if you want?
diff --git a/src/TracedUtils.jl b/src/TracedUtils.jl
index 64619741..7d6d4de1 100644
--- a/src/TracedUtils.jl
+++ b/src/TracedUtils.jl
@@ -278,12 +278,7 @@ function is_pure(func)
if attr isa Nothing
return false
end
- for i in 1:length(attr)
- sa = Base.String(attr[i])
- if sa == "write"
- return false
- end
- end
+ any(at -> String(at) == "write", attr) && return false
return true
end
diff --git a/src/mlir/IR/Attribute.jl b/src/mlir/IR/Attribute.jl
index 1321c3e9..ec12785d 100644
--- a/src/mlir/IR/Attribute.jl
+++ b/src/mlir/IR/Attribute.jl
@@ -802,6 +802,14 @@ function Base.getindex(attr::Attribute, i)
end
end
+function Base.iterate(attr::Attribute, state=1)
+ if state > length(attr)
+ nothing
+ else
+ (attr[state], state + 1)
+ end
+end
+
function Base.getindex(attr::Attribute)
@assert isdenseelements(attr) "attribute $(attr) is not a dense elements attribute"
@assert issplat(attr) "attribute $(attr) is not splatted (more than one different elements)"
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.
go for it!
Co-authored-by: Mosè Giordano <765740+giordano@users.noreply.github.com>
| result_shardings, | ||
| mlir_fn_res.global_device_ids, | ||
| donated_args_mask, | ||
| Reactant.TracedUtils.is_pure(func3) |
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.
[JuliaFormatter] reported by reviewdog 🐶
| Reactant.TracedUtils.is_pure(func3) | |
| Reactant.TracedUtils.is_pure(func3), |
| - `is_pure`: Whether the function being compiled is pure (e.g. has a side effect, like MPI.Send) | ||
| """ | ||
| function codegen_xla_call(flatten_names, nresults, is_sharded::Bool, ndevices::Int) | ||
| function codegen_xla_call(flatten_names, nresults, is_sharded::Bool, ndevices::Int, is_pure::Bool) |
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.
[JuliaFormatter] reported by reviewdog 🐶
| function codegen_xla_call(flatten_names, nresults, is_sharded::Bool, ndevices::Int, is_pure::Bool) | |
| function codegen_xla_call( | |
| flatten_names, nresults, is_sharded::Bool, ndevices::Int, is_pure::Bool | |
| ) |
|
|
||
| concretized_res_names, xla_call_code = codegen_xla_call( | ||
| flatten_arg_names, length(linear_results), mlir_fn_res.is_sharded, ndevices | ||
| flatten_arg_names, length(linear_results), mlir_fn_res.is_sharded, ndevices, mlir_fn_res.is_pure |
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.
[JuliaFormatter] reported by reviewdog 🐶
| flatten_arg_names, length(linear_results), mlir_fn_res.is_sharded, ndevices, mlir_fn_res.is_pure | |
| flatten_arg_names, | |
| length(linear_results), | |
| mlir_fn_res.is_sharded, | |
| ndevices, | |
| mlir_fn_res.is_pure, |
| missing, | ||
| global_device_ids, | ||
| nothing, # populated later in `compile_mlir!` | ||
| is_pure(func2) |
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.
Minor: but not necessary to actually calculate this here since it's recalculated in compile_mlir! I think. Could just pass false instead.
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.
the mlir func may go out of scope so we do need to precompute
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.
Oh I see
|
Looks good from my side besides the comments above |
Co-authored-by: Roman Lee <31547765+romanlee@users.noreply.github.com>
|
This broke building the docs https://github.com/EnzymeAD/Reactant.jl/actions/runs/17802463542/job/50605626751 |
|
oh let me fix that in post, I thought docs failure was expected from some ssl issue but thats clearly not |
No description provided.