-
Notifications
You must be signed in to change notification settings - Fork 39
Add tessera option to @trace
#1986
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
base: main
Are you sure you want to change the base?
Conversation
``` @trace tessera mysin(x)=sin(x) ``` This will add an attribute with name `tessera_name` and value a stringattr with the function name (`"mysin"`) to the generated function for mysin. (note that you need `@code_hlo optimize=false` to see this attribute, otherwise it is inlined.)
lib/ReactantCore/src/ReactantCore.jl
Outdated
| tessera = true | ||
| args = args[2: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.
[JuliaFormatter] reported by reviewdog 🐶
| tessera = true | |
| args = args[2:end] | |
| tessera = true | |
| args = args[2:end] |
lib/ReactantCore/src/ReactantCore.jl
Outdated
| function trace_function_definition(mod, expr; tessera=false) | ||
| internal_fn = MacroTools.splitdef(expr) | ||
| orig_fname = internal_fn[:name] | ||
|
|
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 🐶
lib/ReactantCore/src/ReactantCore.jl
Outdated
|
|
||
| if isempty(new_fn[:kwargs]) | ||
| traced_call_expr = :($(traced_call)($(fname), $(argnames...))) | ||
| traced_call_expr = :($(traced_call)($(fname), $(argnames...); tessera_name=$(String(tessera_name)))) |
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 🐶
| traced_call_expr = :($(traced_call)($(fname), $(argnames...); tessera_name=$(String(tessera_name)))) | |
| traced_call_expr = :($(traced_call)( | |
| $(fname), $(argnames...); tessera_name=$(String(tessera_name)) | |
| )) |
lib/ReactantCore/src/ReactantCore.jl
Outdated
| traced_call_expr = | ||
| :($(traced_call)(Core.kwcall, (; $(kws...)), $(fname), $(argnames...))) | ||
| :($(traced_call)(Core.kwcall, (; $(kws...)), $(fname), $(argnames...); tessera_name=$(String(tessera_name)))) |
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 🐶
| traced_call_expr = | |
| :($(traced_call)(Core.kwcall, (; $(kws...)), $(fname), $(argnames...))) | |
| :($(traced_call)(Core.kwcall, (; $(kws...)), $(fname), $(argnames...); tessera_name=$(String(tessera_name)))) | |
| traced_call_expr = :($(traced_call)( | |
| Core.kwcall, | |
| (; $(kws...)), | |
| $(fname), | |
| $(argnames...); | |
| tessera_name=$(String(tessera_name)), | |
| )) |
src/Ops.jl
Outdated
| end | ||
|
|
||
| @noinline function call(f, args...; location=mlir_stacktrace("call", @__FILE__, @__LINE__)) | ||
| @noinline function call(f, args...; location=mlir_stacktrace("call", @__FILE__, @__LINE__), tessera_name=nothing) |
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 🐶
| @noinline function call(f, args...; location=mlir_stacktrace("call", @__FILE__, @__LINE__), tessera_name=nothing) | |
| @noinline function call( | |
| f, args...; location=mlir_stacktrace("call", @__FILE__, @__LINE__), tessera_name=nothing | |
| ) |
src/Ops.jl
Outdated
| resargprefix, | ||
| ) | ||
| if !isnothing(tessera_name) | ||
| MLIR.IR.attr!(temp.f, "tessera_name", MLIR.IR.Attribute(tessera_name)) |
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 🐶
| MLIR.IR.attr!(temp.f, "tessera_name", MLIR.IR.Attribute(tessera_name)) | |
| MLIR.IR.attr!(temp.f, "tessera_name", MLIR.IR.Attribute(tessera_name)) |
3efbed4 to
d862e5a
Compare
d862e5a to
6804c97
Compare
This will add an attribute with name
tessera_nameand value a stringattr with the function name ("reciprocal") to the generated MLIR function. (note that you need@code_hlo optimize=falseto see this attribute, otherwise it is inlined.)generates code containing:
(note the
tessera_nameattribute)It might be nicer to have a dedicated macro, i.e.:
I just did it this way because it was quicker to reuse some stuff.