From 8a7bedc32ed1ba823046c80debd113094224944e Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Sat, 19 Oct 2024 16:20:23 -0400 Subject: [PATCH] chore: run formatter --- src/public.jl | 8 ++++---- test/misc_tests.jl | 4 ++-- test/runtests.jl | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/public.jl b/src/public.jl index 7a4b5d5..281980e 100644 --- a/src/public.jl +++ b/src/public.jl @@ -348,7 +348,7 @@ for (dev) in (:CPU, :CUDA, :AMDGPU, :Metal, :oneAPI, :XLA) (D::$(ldev))(x::Union{Tuple, NamedTuple}) = map(D, x) function (D::$(ldev))(x) isleaf(x) && return Adapt.adapt(D, x) - return Functors.fmap(D, x, exclude=isleaf) + return Functors.fmap(D, x; exclude=isleaf) end end end @@ -384,10 +384,10 @@ end """ isleaf(x) -> Bool -Returns `true` if `x` is a leaf node in the data structure. +Returns `true` if `x` is a leaf node in the data structure. -Defining `MLDataDevices.isleaf(x::T) = true` for custom types -can be used to customize the behavior the data movement behavior +Defining `MLDataDevices.isleaf(x::T) = true` for custom types +can be used to customize the behavior the data movement behavior when an object with nested structure containing the type is transferred to a device. `Adapt.adapt_structure(::AbstractDevice, x::T)` or diff --git a/test/misc_tests.jl b/test/misc_tests.jl index 3da82ff..942c2ff 100644 --- a/test/misc_tests.jl +++ b/test/misc_tests.jl @@ -163,9 +163,9 @@ end # Functors.isleaf fallback @test MLDataDevices.isleaf(rand(2)) @test !MLDataDevices.isleaf((rand(2),)) - + struct Tleaf - x + x::Any end Functors.@functor Tleaf MLDataDevices.isleaf(::Tleaf) = true diff --git a/test/runtests.jl b/test/runtests.jl index bdca4aa..f3f2596 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -23,8 +23,7 @@ end all_files = ["cuda_tests.jl", "amdgpu_tests.jl", "metal_tests.jl", "oneapi_tests.jl", "xla_tests.jl"] file_names = BACKEND_GROUP == "all" ? all_files : - BACKEND_GROUP ∈ ("cpu", "none") ? [] : - [BACKEND_GROUP * "_tests.jl"] + BACKEND_GROUP ∈ ("cpu", "none") ? [] : [BACKEND_GROUP * "_tests.jl"] @testset "$(file_name)" for file_name in file_names run(`$(Base.julia_cmd()) --color=yes --project=$(dirname(Pkg.project().path)) --startup-file=no --code-coverage=user $(@__DIR__)/$file_name`)