-
Notifications
You must be signed in to change notification settings - Fork 20
WIP: Front end for EnzymeMLIR ProbProg pass #1236
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
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.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
JuliaFormatter
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 153 in b3ba477
result_inference=false |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 157 in b3ba477
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 159 in b3ba477
op_ty_results = IR.Type[result_0, ] |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 164 to 167 in b3ba477
create_operation( | |
"enzyme.init", location; | |
operands, owned_regions, successors, attributes, |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 169 in b3ba477
result_inference=false |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 173 in b3ba477
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 175 in b3ba477
op_ty_results = IR.Type[output, ] |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 180 to 183 in b3ba477
create_operation( | |
"enzyme.placeholder", location; | |
operands, owned_regions, successors, attributes, |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 185 in b3ba477
result_inference=false |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 189 in b3ba477
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 191 to 192 in b3ba477
op_ty_results = IR.Type[output, ] | |
operands = Value[cache, ] |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 196 to 199 in b3ba477
create_operation( | |
"enzyme.pop", location; | |
operands, owned_regions, successors, attributes, |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 201 in b3ba477
result_inference=false |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 205 in b3ba477
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 208 in b3ba477
operands = Value[cache, value, ] |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 212 to 215 in b3ba477
create_operation( | |
"enzyme.push", location; | |
operands, owned_regions, successors, attributes, |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 217 in b3ba477
result_inference=false |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 221 to 224 in b3ba477
function sample(inputs::Vector{Value}; outputs::Vector{IR.Type}, fn, name=nothing, location=Location()) | |
op_ty_results = IR.Type[outputs..., ] | |
operands = Value[inputs..., ] |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 227 in b3ba477
attributes = NamedAttribute[namedattribute("fn", fn), ] |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 229 to 232 in b3ba477
create_operation( | |
"enzyme.sample", location; | |
operands, owned_regions, successors, attributes, |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 234 in b3ba477
result_inference=false |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 238 in b3ba477
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 241 in b3ba477
operands = Value[gradient, value, ] |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 245 to 248 in b3ba477
create_operation( | |
"enzyme.set", location; | |
operands, owned_regions, successors, attributes, |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 250 in b3ba477
result_inference=false |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 261 to 263 in b3ba477
function simulate(inputs::Vector{Value}; trace::IR.Type, fn, name=nothing, location=Location()) | |
op_ty_results = IR.Type[trace, ] | |
operands = Value[inputs..., ] |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 266 in b3ba477
attributes = NamedAttribute[namedattribute("fn", fn), ] |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 268 to 271 in b3ba477
create_operation( | |
"enzyme.simulate", location; | |
operands, owned_regions, successors, attributes, |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 273 in b3ba477
result_inference=false |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 284 to 286 in b3ba477
function trace(inputs::Vector{Value}, oldTrace=nothing::Union{Nothing, Value}; constraints=nothing::Union{Nothing, Value}, newTrace::IR.Type, weights::Vector{IR.Type}, fn, name=nothing, location=Location()) | |
op_ty_results = IR.Type[newTrace, weights..., ] | |
operands = Value[inputs..., ] |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 289 in b3ba477
attributes = NamedAttribute[namedattribute("fn", fn), ] |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 292 in b3ba477
push!(attributes, operandsegmentsizes([length(inputs), (oldTrace==nothing) ? 0 : 1(constraints==nothing) ? 0 : 1])) |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 294 to 297 in b3ba477
create_operation( | |
"enzyme.trace", location; | |
operands, owned_regions, successors, attributes, |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 299 in b3ba477
result_inference=false |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 310 in b3ba477
operands = Value[trace, sample, ] |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 315 to 318 in b3ba477
create_operation( | |
"enzyme.addSampleToTrace", location; | |
operands, owned_regions, successors, attributes, |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 320 in b3ba477
result_inference=false |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 329 to 331 in b3ba477
function insertChoiceToMap(choiceMap::Value, choice::Value; newChoiceMap::IR.Type, name=nothing, location=Location()) | |
op_ty_results = IR.Type[newChoiceMap, ] | |
operands = Value[choiceMap, choice, ] |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 336 to 339 in b3ba477
create_operation( | |
"enzyme.insertChoiceToMap", location; | |
operands, owned_regions, successors, attributes, |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 341 in b3ba477
result_inference=false |
create_operation, | ||
context, | ||
IndexType | ||
import ...IR: NamedAttribute, Value, Location, Block, Region, Attribute, create_operation, context, IndexType |
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 🐶
import ...IR: NamedAttribute, Value, Location, Block, Region, Attribute, create_operation, context, IndexType | |
import ...IR: | |
NamedAttribute, | |
Value, | |
Location, | |
Block, | |
Region, | |
Attribute, | |
create_operation, | |
context, | |
IndexType |
import ..Dialects: namedattribute, operandsegmentsizes | ||
import ...API | ||
|
||
|
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 🐶
""" | ||
`addTo` | ||
|
||
TODO | ||
""" | ||
function addTo(values::Vector{Value}; location=Location()) | ||
op_ty_results = IR.Type[] | ||
operands = Value[values...,] | ||
operands = Value[values..., ] |
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 🐶
operands = Value[values..., ] | |
operands = Value[values...,] |
|
||
create_operation( | ||
"enzyme.addTo", location; | ||
operands, owned_regions, successors, attributes, |
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 🐶
create_operation( | |
"enzyme.addTo", location; | |
operands, owned_regions, successors, attributes, | |
return create_operation( | |
"enzyme.addTo", | |
location; | |
operands, | |
owned_regions, | |
successors, | |
attributes, |
results=op_ty_results, | ||
result_inference=false, | ||
result_inference=false |
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 🐶
result_inference=false | |
result_inference=false, |
!isnothing(library_call) && push!(attributes, namedattribute("library_call", library_call)) | ||
|
||
create_operation( | ||
"enzyme.genericAdjoint", location; | ||
operands, owned_regions, successors, attributes, |
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 🐶
!isnothing(library_call) && push!(attributes, namedattribute("library_call", library_call)) | |
create_operation( | |
"enzyme.genericAdjoint", location; | |
operands, owned_regions, successors, attributes, | |
!isnothing(library_call) && | |
push!(attributes, namedattribute("library_call", library_call)) | |
return create_operation( | |
"enzyme.genericAdjoint", | |
location; | |
operands, | |
owned_regions, | |
successors, | |
attributes, |
results=op_ty_results, | ||
result_inference=false, | ||
result_inference=false |
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 🐶
result_inference=false | |
result_inference=false, |
) | ||
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 🐶
op_ty_results = IR.Type[result_0, ] | ||
operands = Value[gradient, ] |
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 🐶
op_ty_results = IR.Type[result_0, ] | |
operands = Value[gradient, ] | |
op_ty_results = IR.Type[result_0,] | |
operands = Value[gradient,] |
|
||
create_operation( | ||
"enzyme.get", location; | ||
operands, owned_regions, successors, attributes, |
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 🐶
create_operation( | |
"enzyme.get", location; | |
operands, owned_regions, successors, attributes, | |
return create_operation( | |
"enzyme.get", | |
location; | |
operands, | |
owned_regions, | |
successors, | |
attributes, |
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.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
JuliaFormatter
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 284 to 286 in 47e9fe3
function trace(inputs::Vector{Value}, oldTrace=nothing::Union{Nothing, Value}; constraints=nothing::Union{Nothing, Value}, newTrace::IR.Type, weights::Vector{IR.Type}, fn, name=nothing, location=Location()) | |
op_ty_results = IR.Type[newTrace, weights..., ] | |
operands = Value[inputs..., ] |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 289 in 47e9fe3
attributes = NamedAttribute[namedattribute("fn", fn), ] |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 292 in 47e9fe3
push!(attributes, operandsegmentsizes([length(inputs), (oldTrace==nothing) ? 0 : 1(constraints==nothing) ? 0 : 1])) |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 294 to 297 in 47e9fe3
create_operation( | |
"enzyme.trace", location; | |
operands, owned_regions, successors, attributes, |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 299 in 47e9fe3
result_inference=false |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 310 in 47e9fe3
operands = Value[trace, sample, ] |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 315 to 318 in 47e9fe3
create_operation( | |
"enzyme.addSampleToTrace", location; | |
operands, owned_regions, successors, attributes, |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 320 in 47e9fe3
result_inference=false |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 329 to 331 in 47e9fe3
function insertChoiceToMap(choiceMap::Value, choice::Value; outputs::IR.Type, name=nothing, location=Location()) | |
op_ty_results = IR.Type[outputs, ] | |
operands = Value[choiceMap, choice, ] |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Lines 336 to 339 in 47e9fe3
create_operation( | |
"enzyme.insertChoiceToMap", location; | |
operands, owned_regions, successors, attributes, |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/src/mlir/Dialects/Enzyme.jl
Line 341 in 47e9fe3
result_inference=false |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/test/probprog/generate.jl
Lines 30 to 32 in 47e9fe3
@test Array(model_compiled(seed1, μ1, σ1, shape)) ≈ Array(model_compiled(seed1, μ1, σ1, shape)) | |
@test mean(Array(model_compiled(seed1, μ1, σ1, shape))) ≈ 0.0 atol = 0.05 rtol = 0.05 | |
@test mean(Array(model_compiled(seed2, μ2, σ2, shape))) ≈ 1000.0 atol = 0.05 rtol = 0.05 |
[JuliaFormatter] reported by reviewdog 🐶
Reactant.jl/test/probprog/generate.jl
Line 34 in 47e9fe3
Array(model_compiled(seed1, μ1, σ1, shape)) .≈ Array(model_compiled(seed2, μ2, σ2, shape)) |
return result | ||
end | ||
|
||
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 🐶
end | |
end |
results=op_ty_results, | ||
result_inference=false, | ||
result_inference=false |
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 🐶
result_inference=false | |
result_inference=false, |
) | ||
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 🐶
function init(; result_0::IR.Type, location=Location()) | ||
op_ty_results = IR.Type[result_0,] | ||
op_ty_results = IR.Type[result_0, ] |
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 🐶
op_ty_results = IR.Type[result_0, ] | |
op_ty_results = IR.Type[result_0,] |
|
||
create_operation( | ||
"enzyme.init", location; | ||
operands, owned_regions, successors, attributes, |
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 🐶
create_operation( | |
"enzyme.init", location; | |
operands, owned_regions, successors, attributes, | |
return create_operation( | |
"enzyme.init", | |
location; | |
operands, | |
owned_regions, | |
successors, | |
attributes, |
"enzyme.set", location; | ||
operands, owned_regions, successors, attributes, | ||
results=op_ty_results, | ||
result_inference=false |
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 🐶
result_inference=false | |
result_inference=false, |
function simulate(inputs::Vector{Value}; outputs::Vector{IR.Type}, fn, name=nothing, location=Location()) | ||
op_ty_results = IR.Type[outputs..., ] | ||
operands = Value[inputs..., ] |
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 simulate(inputs::Vector{Value}; outputs::Vector{IR.Type}, fn, name=nothing, location=Location()) | |
op_ty_results = IR.Type[outputs..., ] | |
operands = Value[inputs..., ] | |
function simulate( | |
inputs::Vector{Value}; outputs::Vector{IR.Type}, fn, name=nothing, location=Location() | |
) | |
op_ty_results = IR.Type[outputs...,] | |
operands = Value[inputs...,] |
operands = Value[inputs..., ] | ||
owned_regions = Region[] | ||
successors = Block[] | ||
attributes = NamedAttribute[namedattribute("fn", fn), ] |
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 🐶
attributes = NamedAttribute[namedattribute("fn", fn), ] | |
attributes = NamedAttribute[namedattribute("fn", fn),] |
|
||
create_operation( | ||
"enzyme.simulate", location; | ||
operands, owned_regions, successors, attributes, |
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 🐶
create_operation( | |
"enzyme.simulate", location; | |
operands, owned_regions, successors, attributes, | |
return create_operation( | |
"enzyme.simulate", | |
location; | |
operands, | |
owned_regions, | |
successors, | |
attributes, |
"enzyme.simulate", location; | ||
operands, owned_regions, successors, attributes, | ||
results=op_ty_results, | ||
result_inference=false |
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 🐶
result_inference=false | |
result_inference=false, |
WIP: For now just a minimal generate API.