Skip to content

Commit 1281f22

Browse files
ptiedewsmoses
andauthored
Change ReactantCore so that it doesn't depend on Reactant (#1401)
* ReactantCore depended on Reactant in traced * fix * bumpver * Try fix * fix --------- Co-authored-by: William S. Moses <[email protected]> Co-authored-by: William Moses <[email protected]>
1 parent a8a4e1a commit 1281f22

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Reactant"
22
uuid = "3c362404-f566-11ee-1572-e11a4b42c853"
33
authors = ["William Moses <[email protected]>", "Valentin Churavy <[email protected]>", "Sergio Sánchez Ramírez <[email protected]>", "Paul Berg <[email protected]>", "Avik Pal <[email protected]>", "Mosè Giordano <[email protected]>"]
4-
version = "0.2.134"
4+
version = "0.2.135"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
@@ -89,7 +89,7 @@ Preferences = "1.4"
8989
PythonCall = "0.9"
9090
Random = "1.10"
9191
Random123 = "1.7"
92-
ReactantCore = "0.1.12"
92+
ReactantCore = "0.1.15"
9393
Reactant_jll = "0.0.204"
9494
ScopedValues = "1.3.0"
9595
Scratch = "1.2"

lib/ReactantCore/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ReactantCore"
22
uuid = "a3311ec8-5e00-46d5-b541-4f83e724a433"
33
authors = ["William Moses <[email protected]>", "Valentin Churavy <[email protected]>", "Sergio Sánchez Ramírez <[email protected]>", "Paul Berg <[email protected]>", "Avik Pal <[email protected]>"]
4-
version = "0.1.14"
4+
version = "0.1.15"
55

66
[deps]
77
ExpressionExplorer = "21656369-7473-754a-2065-74616d696c43"

lib/ReactantCore/src/ReactantCore.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module ReactantCore
33
using ExpressionExplorer: ExpressionExplorer
44
using MacroTools: MacroTools
55

6-
export @trace, within_compile, MissingTracedValue
6+
export @trace, within_compile, MissingTracedValue, promote_to_traced
77

88
# Traits
99
function is_traced((@nospecialize x::T), seen=Base.IdSet()) where {T}
@@ -34,6 +34,10 @@ const SPECIAL_SYMBOLS = [
3434
:(:), :nothing, :missing, :Inf, :Inf16, :Inf32, :Inf64, :Base, :Core
3535
]
3636

37+
# Function definitions needed to be defined for loop tracing
38+
# Defined in TracedUtils.jl
39+
function promote_to_traced end
40+
3741
"""
3842
within_compile()
3943
@@ -322,16 +326,13 @@ function trace_for(expr; track_numbers, checkpointing, mincut)
322326
$bounds_defs
323327

324328
if $(within_compile)()
325-
$start_sym = Reactant.TracedUtils.promote_to(
326-
Reactant.TracedRNumber{Reactant.unwrapped_eltype(typeof($start_sym))},
329+
$start_sym = $(ReactantCore.promote_to_traced)(
327330
$start_sym,
328331
)
329-
$limit_sym = Reactant.TracedUtils.promote_to(
330-
Reactant.TracedRNumber{Reactant.unwrapped_eltype(typeof($limit_sym))},
332+
$limit_sym = $(ReactantCore.promote_to_traced)(
331333
$limit_sym,
332334
)
333-
$step_sym = Reactant.TracedUtils.promote_to(
334-
Reactant.TracedRNumber{Reactant.unwrapped_eltype(typeof($step_sym))},
335+
$step_sym = $(ReactantCore.promote_to_traced)(
335336
$step_sym,
336337
)
337338
end

src/TracedUtils.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ using ..Reactant:
1515
ReactantPrimitive,
1616
Ops
1717
using ReactantCore: ReactantCore
18-
using ReactantCore: MissingTracedValue, is_traced, materialize_traced_array
18+
using ReactantCore: MissingTracedValue, is_traced, materialize_traced_array, promote_to_traced
1919
using Functors: Functors
2020

21+
function ReactantCore.promote_to_traced(x)
22+
return promote_to(Reactant.TracedRNumber{Reactant.unwrapped_eltype(typeof(x))}, x)
23+
end
24+
25+
2126
ReactantCore.materialize_traced_array(x::AbstractArray) = x
2227

2328
ReactantCore.materialize_traced_array(x::TracedRArray) = x

0 commit comments

Comments
 (0)