794
794
x = Reactant. to_rarray ([1.0 , NaN , Inf , - Inf , NaN ])
795
795
@test @jit (isnan .(x)) == [false , true , false , false , true ]
796
796
797
- x = Reactant. to_rarray ([1.0 , NaN , Inf , - Inf , NaN ] .* im)
798
- @test @jit (isnan .(x)) == [false , true , false , false , true ]
797
+ if ! contains (string (Reactant. devices ()[1 ]), " TPU" )
798
+ x = Reactant. to_rarray ([1.0 , NaN , Inf , - Inf , NaN ] .* im)
799
+ @test @jit (isnan .(x)) == [false , true , false , false , true ]
800
+ end
799
801
end
800
802
801
803
@testset " isnan/isfinite" begin
818
820
b = [6.6 , - 2.2 , - 8.8 , 4.4 , - 10.1 ]
819
821
820
822
expected_mod = mod .(a, b)
821
- @test @jit (mod .(Reactant. to_rarray (a), Reactant. to_rarray (b))) ≈ expected_mod
822
- @test @jit (mod .(a, Reactant. to_rarray (b))) ≈ expected_mod
823
- @test @jit (mod .(Reactant. to_rarray (a), b)) ≈ expected_mod
823
+ if ! contains (string (Reactant. devices ()[1 ]), " TPU" )
824
+ @test @jit (mod .(Reactant. to_rarray (a), Reactant. to_rarray (b))) ≈ expected_mod
825
+ @test @jit (mod .(a, Reactant. to_rarray (b))) ≈ expected_mod
826
+ @test @jit (mod .(Reactant. to_rarray (a), b)) ≈ expected_mod
827
+ end
824
828
825
829
expected_rem = rem .(a, b)
826
830
@test @jit (rem .(Reactant. to_rarray (a), Reactant. to_rarray (b))) ≈ expected_rem
@@ -834,17 +838,22 @@ end
834
838
end
835
839
end
836
840
837
- @testset " signbit" begin
838
- for x in (- 4 , - 3.14 , - 0.0f0 , 0.0 , 0 , 5 , 6.28f0 )
839
- @test @jit (signbit (ConcreteRNumber (x))) == signbit (x)
841
+ if ! contains (string (Reactant. devices ()[1 ]), " TPU" )
842
+ @testset " signbit" begin
843
+ for x in (- 4 , - 3.14 , - 0.0f0 , 0.0 , 0 , 5 , 6.28f0 )
844
+ @test @jit (signbit (ConcreteRNumber (x))) == signbit (x)
845
+ end
840
846
end
841
847
end
842
848
843
- @testset " copysign" begin
844
- for a in (- 3.14 , - 2 , 0.0 , 2.71 , 42 ), b in (- 7 , - 0.57 , - 0.0 , 1 , 3.14 )
845
- # Make sure also the return type is correct
846
- @test Reactant. to_number (@jit (copysign (ConcreteRNumber (a), ConcreteRNumber (b)))) ===
847
- copysign (a, b)
849
+ if ! contains (string (Reactant. devices ()[1 ]), " TPU" )
850
+ @testset " copysign" begin
851
+ for a in (- 3.14 , - 2 , 0.0 , 2.71 , 42 ), b in (- 7 , - 0.57 , - 0.0 , 1 , 3.14 )
852
+ # Make sure also the return type is correct
853
+ @test Reactant. to_number (
854
+ @jit (copysign (ConcreteRNumber (a), ConcreteRNumber (b)))
855
+ ) === copysign (a, b)
856
+ end
848
857
end
849
858
end
850
859
@@ -940,11 +949,13 @@ end
940
949
ra[:a ] ≈ (2.7 * 2 ) * ones (4 )
941
950
end
942
951
943
- @testset " @code_xla" begin
944
- x_ra = Reactant. to_rarray (ones (4 ))
945
- hlo = repr (@code_xla (sin .(x_ra)))
946
- @test contains (hlo, " HloModule" )
947
- @test contains (hlo, " sine" )
952
+ if ! contains (string (Reactant. devices ()[1 ]), " TPU" )
953
+ @testset " @code_xla" begin
954
+ x_ra = Reactant. to_rarray (ones (4 ))
955
+ hlo = repr (@code_xla (sin .(x_ra)))
956
+ @test contains (hlo, " HloModule" )
957
+ @test contains (hlo, " sine" )
958
+ end
948
959
end
949
960
950
961
@testset " Raise keyword" begin
@@ -1129,30 +1140,32 @@ end
1129
1140
end
1130
1141
end
1131
1142
1132
- @testset " Dump MLIR modules" begin
1133
- always_old = Reactant. MLIR. IR. DUMP_MLIR_ALWAYS[]
1134
- dir_old = Reactant. MLIR. IR. DUMP_MLIR_DIR[]
1143
+ if ! contains (string (Reactant. devices ()[1 ]), " TPU" )
1144
+ @testset " Dump MLIR modules" begin
1145
+ always_old = Reactant. MLIR. IR. DUMP_MLIR_ALWAYS[]
1146
+ dir_old = Reactant. MLIR. IR. DUMP_MLIR_DIR[]
1147
+
1148
+ mktempdir () do dir
1149
+ Reactant. MLIR. IR. DUMP_MLIR_ALWAYS[] = true
1150
+ Reactant. MLIR. IR. DUMP_MLIR_DIR[] = dir
1151
+ @compile sin .(Reactant. to_rarray (Float32[1.0 ]))
1152
+ for mod in readdir (dir; join= true )
1153
+ @test contains (read (mod, String), " hlo.sine" )
1154
+ end
1155
+ end
1135
1156
1136
- mktempdir () do dir
1137
- Reactant. MLIR. IR. DUMP_MLIR_ALWAYS[] = true
1138
- Reactant. MLIR. IR. DUMP_MLIR_DIR[] = dir
1139
- @compile sin .(Reactant. to_rarray (Float32[1.0 ]))
1140
- for mod in readdir (dir; join= true )
1141
- @test contains (read (mod, String), " hlo.sine" )
1157
+ mktempdir () do dir
1158
+ Reactant. MLIR. IR. DUMP_MLIR_ALWAYS[] = false
1159
+ Reactant. MLIR. IR. DUMP_MLIR_DIR[] = dir
1160
+ @compile exp .(Reactant. to_rarray (Float32[1.0 ]))
1161
+ # Make sure we don't save anything to file when compilation is
1162
+ # successful and `DUMP_MLIR_ALWAYS=false`.
1163
+ @test isempty (readdir (dir; join= true ))
1142
1164
end
1143
- end
1144
1165
1145
- mktempdir () do dir
1146
- Reactant. MLIR. IR. DUMP_MLIR_ALWAYS[] = false
1147
- Reactant. MLIR. IR. DUMP_MLIR_DIR[] = dir
1148
- @compile exp .(Reactant. to_rarray (Float32[1.0 ]))
1149
- # Make sure we don't save anything to file when compilation is
1150
- # successful and `DUMP_MLIR_ALWAYS=false`.
1151
- @test isempty (readdir (dir; join= true ))
1166
+ Reactant. MLIR. IR. DUMP_MLIR_ALWAYS[] = always_old
1167
+ Reactant. MLIR. IR. DUMP_MLIR_DIR[] = dir_old
1152
1168
end
1153
-
1154
- Reactant. MLIR. IR. DUMP_MLIR_ALWAYS[] = always_old
1155
- Reactant. MLIR. IR. DUMP_MLIR_DIR[] = dir_old
1156
1169
end
1157
1170
1158
1171
@testset " Allocator Stats" begin
0 commit comments