-
Notifications
You must be signed in to change notification settings - Fork 9
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
MLIRValueTrait to support user defined Value types #64
base: main
Are you sure you want to change the base?
Conversation
deps/tblgen/jl-generators.cc
Outdated
@@ -197,7 +197,7 @@ function {0}({1}location=Location()) | |||
end | |||
)"; // 0: functionname, 1: functionarguments, 2: functionbody | |||
const char *functionbodytemplate = R"(results = IR.Type[{0}] | |||
operands = Value[{1}] |
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.
Why use API.MlirValue
instead of IR.Value
?
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.
You're right, I don't it should.
Co-authored-by: Sergio Sánchez Ramírez <[email protected]>
Co-authored-by: Sergio Sánchez Ramírez <[email protected]>
Co-authored-by: Sergio Sánchez Ramírez <[email protected]>
Thanks for the changes @mofeing! What do you think of using |
I like to use constructor methods (i.e. The problem with I'm not sure in which cases you will need to convert from some other type to EDIT: Can you give me some example where you need to convert some other type to |
Isn't this the case here then? The standard assumption is that these value-like types have a field holding an actual
Actually, the one example I had one was to get rid of explicit conversions when pushing to the operands array in generated dialect wrappers. e.g.: function addf(lhs, rhs; result=nothing::Union{Nothing, IR.Type}, fastmath=nothing, location=Location())
results = IR.Type[]
operands = IR.Value[lhs, rhs] # instead of IR.Value[value(lhs), value(rhs)]
But upon thinking more about this, that really isn't a good use-case as this code is auto-generated in the first place and the implicit conversion might cause more confusion elsewhere. Conversion in the other direction could be more interesting, though. For example, an explicit return type for a function would convert whatever result that that function returns automatically. But again, this might cause more confusion, so maybe left best for later down the line in a different pr. Do we merge this pr once the naming has decided or are there other considerations? |
I'm ok with merging as it is but you just need to update the other Line 124 in d438d41
|
…lue in jl-generator
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #64 +/- ##
========================================
- Coverage 2.28% 2.28% -0.01%
========================================
Files 125 125
Lines 28527 28532 +5
========================================
Hits 653 653
- Misses 27874 27879 +5 ☔ View full report in Codecov by Sentry. |
I've updated MLIR_jll to also accept v17, so the CI failing on Julia nightly should no longer fail. Anyway, you're free to merge whenever you want to. |
Thanks for the heads up, and for your CI work! The error seems to be an Pkg environment conflict so not sure what could be causing this as I kind of lost the plot with this PR. I'm currently prepping a branch with my work on generating MLIR from Julia code that will supersede this one so this shouldn't be merged anymore. |
What this enables:
Of course, using this approach you lose direct access to a handle to the generated operation (
arith.addi
) so it is of dubious value as of now.In Jojo.jl this system is used in combination with CassetteOverlay to make sure that all created operations are collected. This system is still a bit finicky and I'm still working on it so I wouldn't try upstream this yet.
While collecting things to push here, it's clear some cleaning up is still required.
get_value
is a bad name. It could be changed toValue
, or instead, use Julia conversionconvert(::Value, ...)
which would probably be nicer to allow automatic conversion when e.g. pushing toValue[]
MLIRValueTrait
=>ValueTrait
?I'm not even sure if it's necessary to have this trait system. For now, the conversion to
IR.Value
is so simple that you might as well just specializeget_value
instead of letting it happen through the trait. On the other hand, this might help in the future as people want to add extra functionality to Value-like types.