Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
chore: run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Oct 19, 2024
1 parent ffa0fb8 commit 8a7bedc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/public.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/misc_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down

0 comments on commit 8a7bedc

Please sign in to comment.