Skip to content

Commit f46e44d

Browse files
authored
Remove marktype (#2233)
1 parent 378dc21 commit f46e44d

File tree

3 files changed

+2
-100
lines changed

3 files changed

+2
-100
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Enzyme"
22
uuid = "7da242da-08ed-463a-9acd-ee780be4f1d9"
33
authors = ["William Moses <wmoses@mit.edu>", "Valentin Churavy <vchuravy@mit.edu>"]
4-
version = "0.13.25"
4+
version = "0.13.26"
55

66
[deps]
77
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"

src/Enzyme.jl

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export autodiff,
9999
make_zero!
100100

101101
export jacobian, gradient, gradient!, hvp, hvp!, hvp_and_gradient!
102-
export markType, batch_size, onehot, chunkedonehot
102+
export batch_size, onehot, chunkedonehot
103103

104104
using LinearAlgebra
105105
import SparseArrays
@@ -1446,78 +1446,6 @@ result, ∂v, ∂A
14461446
aug_thunk, adj_thunk
14471447
end
14481448

1449-
# White lie, should be `Core.LLVMPtr{Cvoid, 0}` but that's not supported by ccallable
1450-
Base.@ccallable function __enzyme_float(x::Ptr{Cvoid})::Cvoid
1451-
return nothing
1452-
end
1453-
1454-
Base.@ccallable function __enzyme_double(x::Ptr{Cvoid})::Cvoid
1455-
return nothing
1456-
end
1457-
1458-
@inline function markType(::Type{T}, ptr::Ptr{Cvoid}) where {T}
1459-
markType(Base.unsafe_convert(Ptr{T}, ptr))
1460-
end
1461-
1462-
@inline function markType(data::Array{T}) where {T}
1463-
GC.@preserve data markType(pointer(data))
1464-
end
1465-
1466-
# TODO(WM): We record the type of a single index here, we could give it a range
1467-
@inline function markType(data::SubArray)
1468-
GC.@preserve data markType(pointer(data))
1469-
end
1470-
1471-
@inline function markType(data::Ptr{Float32})
1472-
@static if sizeof(Int) == sizeof(Int64)
1473-
Base.llvmcall(
1474-
(
1475-
"declare void @__enzyme_float(i8* nocapture) nounwind define void @c(i64 %q) nounwind alwaysinline { %p = inttoptr i64 %q to i8* call void @__enzyme_float(i8* %p) ret void }",
1476-
"c",
1477-
),
1478-
Cvoid,
1479-
Tuple{Ptr{Float32}},
1480-
data,
1481-
)
1482-
else
1483-
Base.llvmcall(
1484-
(
1485-
"declare void @__enzyme_float(i8* nocapture) nounwind define void @c(i32 %q) nounwind alwaysinline { %p = inttoptr i32 %q to i8* call void @__enzyme_float(i8* %p) ret void }",
1486-
"c",
1487-
),
1488-
Cvoid,
1489-
Tuple{Ptr{Float32}},
1490-
data,
1491-
)
1492-
end
1493-
nothing
1494-
end
1495-
1496-
@inline function markType(data::Ptr{Float64})
1497-
@static if sizeof(Int) == sizeof(Int64)
1498-
Base.llvmcall(
1499-
(
1500-
"declare void @__enzyme_double(i8* nocapture) nounwind define void @c(i64 %q) nounwind alwaysinline { %p = inttoptr i64 %q to i8* call void @__enzyme_double(i8* %p) ret void }",
1501-
"c",
1502-
),
1503-
Cvoid,
1504-
Tuple{Ptr{Float64}},
1505-
data,
1506-
)
1507-
else
1508-
Base.llvmcall(
1509-
(
1510-
"declare void @__enzyme_double(i8* nocapture) nounwind define void @c(i32 %q) nounwind alwaysinline { %p = inttoptr i32 %q to i8* call void @__enzyme_double(i8* %p) ret void }",
1511-
"c",
1512-
),
1513-
Cvoid,
1514-
Tuple{Ptr{Float64}},
1515-
data,
1516-
)
1517-
end
1518-
nothing
1519-
end
1520-
15211449
include("sugar.jl")
15221450

15231451
function _import_frule end # defined in EnzymeChainRulesCoreExt extension

test/runtests.jl

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,32 +2374,6 @@ end
23742374
@test Enzyme.autodiff(Forward, timsteploop, Duplicated(2.0, 1.0))[1] 1.0
23752375
end
23762376

2377-
@testset "Type" begin
2378-
function foo(in::Ptr{Cvoid}, out::Ptr{Cvoid})
2379-
markType(Float64, in)
2380-
ccall(:memcpy,Cvoid, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), out, in, 8)
2381-
end
2382-
2383-
x = [2.0]
2384-
y = [3.0]
2385-
dx = [5.0]
2386-
dy = [7.0]
2387-
2388-
@test markType(x) === nothing
2389-
@test markType(zeros(Float32, 64)) === nothing
2390-
@test markType(view(zeros(64), 16:32)) === nothing
2391-
2392-
GC.@preserve x y begin
2393-
foo(Base.unsafe_convert(Ptr{Cvoid}, x), Base.unsafe_convert(Ptr{Cvoid}, y))
2394-
end
2395-
2396-
GC.@preserve x y dx dy begin
2397-
autodiff(Reverse, foo,
2398-
Duplicated(Base.unsafe_convert(Ptr{Cvoid}, x), Base.unsafe_convert(Ptr{Cvoid}, dx)),
2399-
Duplicated(Base.unsafe_convert(Ptr{Cvoid}, y), Base.unsafe_convert(Ptr{Cvoid}, dy)))
2400-
end
2401-
end
2402-
24032377
function bc0_test_function(ps)
24042378
z = view(ps, 26:30)
24052379
C = Matrix{Float64}(undef, 5, 1)

0 commit comments

Comments
 (0)