Skip to content
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

remove :loopinfo from IR #154

Merged
merged 2 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ version = "0.4.4"

[[deps.Adapt]]
deps = ["LinearAlgebra", "Requires"]
git-tree-sha1 = "cc37d689f599e8df4f464b2fa3870ff7db7492ef"
git-tree-sha1 = "76289dc51920fdc6e0013c872ba9551d54961c24"
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
version = "3.6.1"
version = "3.6.2"
weakdeps = ["StaticArrays"]

[deps.Adapt.extensions]
Expand All @@ -33,9 +33,9 @@ version = "1.49.0"

[[deps.ChainRulesCore]]
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "c6d890a52d2c4d55d326439580c3b8d0875a77d9"
git-tree-sha1 = "e30f2f4e20f7f186dc36529910beaedc60cfa644"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "1.15.7"
version = "1.16.0"

[[deps.CodeTracking]]
deps = ["InteractiveUtils", "UUIDs"]
Expand Down Expand Up @@ -65,14 +65,14 @@ version = "1.0.2+0"

[[deps.Cthulhu]]
deps = ["CodeTracking", "FoldingTrees", "InteractiveUtils", "JuliaSyntax", "PrecompileTools", "Preferences", "REPL", "TypedSyntax", "UUIDs", "Unicode", "WidthLimitedIO"]
git-tree-sha1 = "4e396fa7a2f2570f02839e04be6af0744610dbc4"
git-tree-sha1 = "aac06850ca054d0459ec212aed9788f60dbf79cf"
uuid = "f68482b8-f384-11e8-15f7-abe071a5a75f"
version = "2.8.14"
version = "2.8.15"

[[deps.DataAPI]]
git-tree-sha1 = "e8119c1a33d267e16108be441a287a6981ba1630"
git-tree-sha1 = "8da84edb865b0b5b0100c0666a9bc9a0b71c553c"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.14.0"
version = "1.15.0"

[[deps.DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
Expand Down Expand Up @@ -107,9 +107,9 @@ version = "1.2.1"

[[deps.GPUArraysCore]]
deps = ["Adapt"]
git-tree-sha1 = "1cd7f0af1aa58abc02ea1d872953a97359cb87fa"
git-tree-sha1 = "2d6ca471a6c7b536127afccfa7564b5b39227fe0"
uuid = "46192b85-c4d5-4398-a991-12ede77f4527"
version = "0.1.4"
version = "0.1.5"

[[deps.InteractiveUtils]]
deps = ["Markdown"]
Expand All @@ -126,9 +126,9 @@ uuid = "82899510-4779-5014-852e-03e436cf321d"
version = "1.0.0"

[[deps.JuliaSyntax]]
git-tree-sha1 = "e09bf943597f83cc7a1fe3ae6c01c2c008d8cde7"
git-tree-sha1 = "3884259b6852ed89c7036c455551a556d8a3a124"
uuid = "70703baa-626e-46a2-a12c-08ffd08c73b4"
version = "0.3.5"
version = "0.4.1"

[[deps.LibGit2]]
deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
Expand Down Expand Up @@ -192,9 +192,9 @@ version = "1.6.0"

[[deps.PrecompileTools]]
deps = ["Preferences"]
git-tree-sha1 = "d0984cc886c48e5a165705ce65236dc2ec467b91"
git-tree-sha1 = "259e206946c293698122f63e2b513a7c99a244e8"
uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
version = "1.1.0"
version = "1.1.1"

[[deps.Preferences]]
deps = ["TOML"]
Expand Down Expand Up @@ -249,9 +249,9 @@ version = "1.10.0"

[[deps.StaticArrays]]
deps = ["LinearAlgebra", "Random", "StaticArraysCore", "Statistics"]
git-tree-sha1 = "c262c8e978048c2b095be1672c9bee55b4619521"
git-tree-sha1 = "8982b3607a212b070a5e46eea83eb62b4744ae12"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.5.24"
version = "1.5.25"

[[deps.StaticArraysCore]]
git-tree-sha1 = "6b7ba252635a5eff6a0b0664a41ee140a1c9e72a"
Expand Down Expand Up @@ -304,9 +304,9 @@ uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[deps.TypedSyntax]]
deps = ["CodeTracking", "JuliaSyntax"]
git-tree-sha1 = "fa9ca390d3b437f35c9ab33954fc0b294b011e09"
git-tree-sha1 = "6da6670f978221bea4f501b600f34ec20cb9516e"
uuid = "d265eb64-f81a-44ad-a842-4247ee1503de"
version = "1.1.9"
version = "1.1.10"

[[deps.UUIDs]]
deps = ["Random", "SHA"]
Expand All @@ -324,4 +324,4 @@ version = "1.0.1"
[[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "5.7.0+0"
version = "5.8.0+0"
3 changes: 2 additions & 1 deletion src/codegen/forward.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ function fwd_transform!(ci, mi, nargs, N)
return ZeroBundle{N}(mi.sparam_vals[stmt.args[1]::Int])
elseif isexpr(stmt, :foreigncall)
return Expr(:call, error, "Attempted to AD a foreigncall. Missing rule?")
elseif isexpr(stmt, :meta) || isexpr(stmt, :inbounds)
elseif isexpr(stmt, :meta) || isexpr(stmt, :inbounds) || isexpr(stmt, :loopinfo)
# Can't trust that meta annotations are still valid in the AD'd
# version.
return nothing
else
#TODO put guard here. We really don't want invalid IR
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not in general invalid IR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposal here is rather that we assert that this is only getting various kinds of literals to wrap in a ZeroBundle (be they functions or numbers etc)
and if not give a good error message, rather than generating invalid IR.

return Expr(:call, ZeroBundle{N}, stmt)
end
end
Expand Down
2 changes: 2 additions & 0 deletions src/codegen/forward_demand.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ function forward_visit!(ir::IRCode, ssa::SSAValue, order::Int, ssa_orders::Vecto
recurse(stmt)
elseif isexpr(stmt, :code_coverage_effect)
return
elseif isexpr(stmt, :loopinfo) #TODO preserve this properly
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not legal to preserve.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can't be outright preserved but we might be able to do something with this infromation

return
elseif !isa(stmt, Expr)
return
else
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ let var"'" = Diffractor.PrimeDerivativeFwd
@test sin''''''(1.0) == -sin(1.0)
@test cos''''''(1.0) == -cos(1.0)
@test exp''''''(1.0) == exp(1.0)
@test (x->prod([x, 4]))'(3) == 4
end

# Some Basic Mixed Mode tests
Expand Down