|
218 | 218 | end |
219 | 219 |
|
220 | 220 | @testset "concatenation" begin |
| 221 | + @testset "Number" begin |
| 222 | + x = fill(true) |
| 223 | + x_concrete = Reactant.to_rarray(x) |
| 224 | + |
| 225 | + # NOTE [,,,] is a call to `vect`, not `*cat` |
| 226 | + # f = Reactant.compile((x_concrete,)) do x |
| 227 | + # return [x, x, x] |
| 228 | + # end |
| 229 | + # @test f(x_concrete) ≈ ones(3) |
| 230 | + |
| 231 | + # vcat |
| 232 | + test_vcat(x) = begin |
| 233 | + x = x[] # unwrap scalar |
| 234 | + [x; x; x] |
| 235 | + end |
| 236 | + f = @compile test_vcat(x_concrete) |
| 237 | + @test f(x_concrete) == test_vcat(x) |
| 238 | + @test eltype(f(x_concrete)) === Bool |
| 239 | + |
| 240 | + # hcat |
| 241 | + test_hcat(x) = begin |
| 242 | + x = x[] # unwrap scalar |
| 243 | + [x x x] |
| 244 | + end |
| 245 | + f = @compile test_hcat(x_concrete) |
| 246 | + @test f(x_concrete) == test_hcat(x) |
| 247 | + @test eltype(f(x_concrete)) === Bool |
| 248 | + |
| 249 | + # hvcat |
| 250 | + test_hvcat(x) = begin |
| 251 | + x = x[] # unwrap scalar |
| 252 | + [x x x; x x x] |
| 253 | + end |
| 254 | + f = @compile test_hvcat(x_concrete) |
| 255 | + @test f(x_concrete) == test_hvcat(x) |
| 256 | + @test eltype(f(x_concrete)) === Bool |
| 257 | + |
| 258 | + # hvncat |
| 259 | + test_hvncat(x) = begin |
| 260 | + x = x[] # unwrap scalar |
| 261 | + [x x x; x x x;;; x x x; x x x] |
| 262 | + end |
| 263 | + f = @compile test_hvncat(x_concrete) |
| 264 | + @test f(x_concrete) == test_hvncat(x) |
| 265 | + @test eltype(f(x_concrete)) === Bool |
| 266 | + |
| 267 | + # typed_vcat |
| 268 | + test_typed_vcat(x) = begin |
| 269 | + x = x[] # unwrap scalar |
| 270 | + Int[x; x; x] |
| 271 | + end |
| 272 | + f = @compile test_typed_vcat(x_concrete) |
| 273 | + @test f(x_concrete) == test_typed_vcat(x) |
| 274 | + @test eltype(f(x_concrete)) === Int |
| 275 | + |
| 276 | + # typed_hcat |
| 277 | + test_typed_hcat(x) = begin |
| 278 | + x = x[] # unwrap scalar |
| 279 | + Int[x x x] |
| 280 | + end |
| 281 | + f = @compile test_typed_hcat(x_concrete) |
| 282 | + @test f(x_concrete) == test_typed_hcat(x) |
| 283 | + @test eltype(f(x_concrete)) === Int |
| 284 | + |
| 285 | + # typed_hvcat |
| 286 | + test_typed_hvcat(x) = begin |
| 287 | + x = x[] # unwrap scalar |
| 288 | + Int[x x x; x x x] |
| 289 | + end |
| 290 | + f = @compile test_typed_hvcat(x_concrete) |
| 291 | + @test f(x_concrete) == test_typed_hvcat(x) |
| 292 | + @test eltype(f(x_concrete)) === Int |
| 293 | + |
| 294 | + # typed_hvncat |
| 295 | + test_typed_hvncat(x) = begin |
| 296 | + x = x[] # unwrap scalar |
| 297 | + Int[x x x; x x x;;; x x x; x x x] |
| 298 | + end |
| 299 | + f = @compile test_typed_hvncat(x_concrete) |
| 300 | + @test f(x_concrete) == test_typed_hvncat(x) |
| 301 | + @test eltype(f(x_concrete)) === Int |
| 302 | + end |
| 303 | + |
221 | 304 | @testset "$(ndims(x))-dim" for x in [ |
222 | 305 | fill(true), |
223 | 306 | [true, false], |
|
0 commit comments