Skip to content

Commit 309dce0

Browse files
committed
test: object not copied
1 parent 2eb1019 commit 309dce0

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

lib/MLDataDevices/test/amdgpu_tests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ using FillArrays, Zygote # Extensions
124124
return_val(x) = Val(get_device_type(x)) # If it is a compile time constant then type inference will work
125125
@test @inferred(return_val(ps)) isa Val{parameterless_type(typeof(device))}
126126
end
127+
128+
@testset "Issue #1129: no new object" begin
129+
x = rand(Float32, 10, 10) |> device
130+
y = x |> device
131+
@test x === y
132+
end
127133
end
128134

129135
@testset "Functions" begin

lib/MLDataDevices/test/cuda_tests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ using FillArrays, Zygote # Extensions
149149
return_val2(x) = Val(get_device(x))
150150
@test_throws ErrorException @inferred(return_val2(ps))
151151
end
152+
153+
@testset "Issue #1129: no new object" begin
154+
x = rand(Float32, 10, 10) |> device
155+
y = x |> device
156+
@test x === y
157+
end
152158
end
153159

154160
@testset "Functions" begin

lib/MLDataDevices/test/metal_tests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ using FillArrays, Zygote # Extensions
113113
return_val2(x) = Val(get_device(x))
114114
@test @inferred(return_val2(ps)) isa Val{get_device(x)}
115115
end
116+
117+
@testset "Issue #1129: no new object" begin
118+
x = rand(Float32, 10, 10) |> device
119+
y = x |> device
120+
@test x === y
121+
end
116122
end
117123

118124
@testset "Functions" begin

lib/MLDataDevices/test/oneapi_tests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ using FillArrays, Zygote # Extensions
113113
return_val2(x) = Val(get_device(x))
114114
@test @inferred(return_val2(ps)) isa Val{get_device(x)}
115115
end
116+
117+
@testset "Issue #1129: no new object" begin
118+
x = rand(Float32, 10, 10) |> device
119+
y = x |> device
120+
@test x === y
121+
end
116122
end
117123

118124
@testset "Functions" begin

lib/MLDataDevices/test/xla_tests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ using FillArrays, Zygote # Extensions
113113
return_val2(x) = Val(get_device(x))
114114
@test_throws TypeError @inferred(return_val2(ps))
115115
end
116+
117+
@testset "Issue #1129: no new object" begin
118+
x = rand(Float32, 10, 10) |> device
119+
y = x |> device
120+
@test x === y
121+
end
116122
end
117123

118124
@testset "Functions" begin

0 commit comments

Comments
 (0)