Skip to content

Commit 21fbf4f

Browse files
authored
Refactor rule derivation slightly (#537)
* Avoid extra function call * Insert more things directly * Fix bug * Fix issue * Revert previous change * Revert accidental change * Bump patch version
1 parent eb5cde1 commit 21fbf4f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Mooncake"
22
uuid = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
33
authors = ["Will Tebbutt, Hong Ge, and contributors"]
4-
version = "0.4.111"
4+
version = "0.4.112"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

src/interpreter/s2s_reverse_mode_ad.jl

+6-3
Original file line numberDiff line numberDiff line change
@@ -699,9 +699,12 @@ function make_ad_stmts!(stmt::Expr, line::ID, info::ADInfo)
699699
#
700700

701701
# Make arguments to rrule call. Things which are not already CoDual must be made so.
702-
codual_arg_ids = map(_ -> ID(), collect(args))
703-
codual_args = map(args, codual_arg_ids) do arg, id
704-
return (id, new_inst(inc_or_const_stmt(arg, info)))
702+
codual_args = IDInstPair[]
703+
codual_arg_ids = map(args) do arg
704+
is_active(arg) && return __inc(arg)
705+
id = ID()
706+
push!(codual_args, (id, new_inst(inc_or_const_stmt(arg, info))))
707+
return id
705708
end
706709

707710
# Make call to rule.

0 commit comments

Comments
 (0)