Skip to content

Commit 6506040

Browse files
authored
Merge pull request #113 from EnzymeAD/format-main
Format code of branch "main"
2 parents bca7438 + d6e7726 commit 6506040

File tree

4 files changed

+111
-59
lines changed

4 files changed

+111
-59
lines changed

benchmark/benchmarks.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ for depth in [11, 13, 16, 19]
3131
end setup = begin
3232
vgg = Vision.VGG($depth; pretrained=false, batchnorm=false)
3333
ps, st = Lux.setup(Random.default_rng(), vgg)
34-
ps_concrete = ps |> Reactant.to_rarray
35-
st_concrete = st |> Lux.testmode |> Reactant.to_rarray
36-
x = rand(Float32, 224, 224, 3, 16) |> Reactant.to_rarray
34+
ps_concrete = Reactant.to_rarray(ps)
35+
st_concrete = Reactant.to_rarray(Lux.testmode(st))
36+
x = Reactant.to_rarray(rand(Float32, 224, 224, 3, 16))
3737
end
3838
end
3939

deps/ReactantExtra/make.jl

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,47 @@
1-
import BinaryBuilderBase: PkgSpec, Prefix, temp_prefix, setup_dependencies, cleanup_dependencies, destdir
1+
import BinaryBuilderBase:
2+
PkgSpec, Prefix, temp_prefix, setup_dependencies, cleanup_dependencies, destdir
23
using Clang.Generators
34

45
options = load_options(joinpath(@__DIR__, "wrap.toml"))
56

6-
function rewrite!(dag::ExprDAG)
7-
end
7+
function rewrite!(dag::ExprDAG) end
88

99
@add_def off_t
1010
@add_def MlirTypesCallback
1111

1212
let options = deepcopy(options)
1313
options["general"]["output_file_path"] = ARGS[end]
1414

15-
include_dir = joinpath(splitpath(ARGS[1])[1:end-4]...)
15+
include_dir = joinpath(splitpath(ARGS[1])[1:(end - 4)]...)
1616
args = Generators.get_default_args()
17-
ll_include_dir = joinpath(splitpath(ARGS[2])[1:end-2]...)
17+
ll_include_dir = joinpath(splitpath(ARGS[2])[1:(end - 2)]...)
1818

1919
genarg = first(eachsplit(ARGS[3], " "))
2020

21-
gen_include_dir = joinpath(splitpath(genarg)[1:end-3]...)
22-
23-
hlo_include_dir = joinpath(splitpath(ARGS[end-1])[1:end-1]...)
24-
25-
append!(args, ["-I", include_dir, "-I", ll_include_dir,"-I", gen_include_dir,"-I", hlo_include_dir, "-x", "c++"])
26-
27-
headers = [detect_headers(include_dir, args, Dict(), endswith("Python/Interop.h"))..., detect_headers(hlo_include_dir, args, Dict())...]
21+
gen_include_dir = joinpath(splitpath(genarg)[1:(end - 3)]...)
22+
23+
hlo_include_dir = joinpath(splitpath(ARGS[end - 1])[1:(end - 1)]...)
24+
25+
append!(
26+
args,
27+
[
28+
"-I",
29+
include_dir,
30+
"-I",
31+
ll_include_dir,
32+
"-I",
33+
gen_include_dir,
34+
"-I",
35+
hlo_include_dir,
36+
"-x",
37+
"c++",
38+
],
39+
)
40+
41+
headers = [
42+
detect_headers(include_dir, args, Dict(), endswith("Python/Interop.h"))...,
43+
detect_headers(hlo_include_dir, args, Dict())...,
44+
]
2845

2946
ctx = create_context(headers, args, options)
3047

@@ -35,4 +52,4 @@ let options = deepcopy(options)
3552

3653
# print
3754
build!(ctx, BUILDSTAGE_PRINTING_ONLY)
38-
end
55+
end

deps/build_local.jl

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ Pkg.activate(; temp=true)
1818
# Build!
1919
@info "Building" source_dir scratch_dir
2020
run(`mkdir -p $(scratch_dir)`)
21-
run(Cmd(`$(Base.julia_cmd().exec[1]) --project=. -e "using Pkg; Pkg.instantiate()"`, dir=source_dir))
21+
run(
22+
Cmd(
23+
`$(Base.julia_cmd().exec[1]) --project=. -e "using Pkg; Pkg.instantiate()"`;
24+
dir=source_dir,
25+
),
26+
)
2227

2328
#--repo_env TF_NEED_ROCM=1
2429
#--define=using_rocm=true --define=using_rocm_hipcc=true
@@ -45,7 +50,7 @@ end
4550

4651
build_kind = if length(ARGS) == 1
4752
kind = ARGS[1]
48-
if kind ("dbg", "opt")
53+
if kind ("dbg", "opt")
4954
error("Invalid build kind $(kind). Valid options are 'dbg' and 'opt'")
5055
end
5156
kind
@@ -56,20 +61,33 @@ end
5661
@info "Building JLL with -c $(build_kind)"
5762

5863
if isempty(arg)
59-
run(Cmd(`bazel build -c $(build_kind) --action_env=JULIA=$(Base.julia_cmd().exec[1])
64+
run(
65+
Cmd(
66+
`bazel build -c $(build_kind) --action_env=JULIA=$(Base.julia_cmd().exec[1])
6067
--repo_env HERMETIC_PYTHON_VERSION="3.10"
61-
--check_visibility=false --verbose_failures :libReactantExtra.so :Builtin.inc.jl :Arith.inc.jl :Affine.inc.jl :Func.inc.jl :Enzyme.inc.jl :StableHLO.inc.jl :CHLO.inc.jl :VHLO.inc.jl`, dir=source_dir,
62-
))
68+
--check_visibility=false --verbose_failures :libReactantExtra.so :Builtin.inc.jl :Arith.inc.jl :Affine.inc.jl :Func.inc.jl :Enzyme.inc.jl :StableHLO.inc.jl :CHLO.inc.jl :VHLO.inc.jl`;
69+
dir=source_dir,
70+
),
71+
)
6372
else
64-
run(Cmd(`bazel build $(arg) -c $(build_kind) --action_env=JULIA=$(Base.julia_cmd().exec[1])
73+
run(
74+
Cmd(
75+
`bazel build $(arg) -c $(build_kind) --action_env=JULIA=$(Base.julia_cmd().exec[1])
6576
--repo_env HERMETIC_PYTHON_VERSION="3.10"
66-
--check_visibility=false --verbose_failures :libReactantExtra.so :Builtin.inc.jl :Arith.inc.jl :Affine.inc.jl :Func.inc.jl :Enzyme.inc.jl :StableHLO.inc.jl :CHLO.inc.jl :VHLO.inc.jl`, dir=source_dir,
67-
))
77+
--check_visibility=false --verbose_failures :libReactantExtra.so :Builtin.inc.jl :Arith.inc.jl :Affine.inc.jl :Func.inc.jl :Enzyme.inc.jl :StableHLO.inc.jl :CHLO.inc.jl :VHLO.inc.jl`;
78+
dir=source_dir,
79+
),
80+
)
6881
end
6982
# env=Dict("HOME"=>ENV["HOME"], "PATH"=>joinpath(source_dir, "..")*":"*ENV["PATH"])))
7083

71-
run(Cmd(`rm -f libReactantExtra.dylib`, dir=joinpath(source_dir, "bazel-bin")))
72-
run(Cmd(`ln -s libReactantExtra.so libReactantExtra.dylib`, dir=joinpath(source_dir, "bazel-bin")))
84+
run(Cmd(`rm -f libReactantExtra.dylib`; dir=joinpath(source_dir, "bazel-bin")))
85+
run(
86+
Cmd(
87+
`ln -s libReactantExtra.so libReactantExtra.dylib`;
88+
dir=joinpath(source_dir, "bazel-bin"),
89+
),
90+
)
7391

7492
# Discover built libraries
7593
built_libs = filter(readdir(joinpath(source_dir, "bazel-bin"))) do file
@@ -84,6 +102,6 @@ set_preferences!(
84102
joinpath(dirname(@__DIR__), "LocalPreferences.toml"),
85103
"Reactant_jll",
86104
"libReactantExtra_path" => lib_path,
87-
"libReactantDialects_path" => joinpath(source_dir, "bazel-bin"),
105+
"libReactantDialects_path" => joinpath(source_dir, "bazel-bin");
88106
force=true,
89107
)

docs/make.jl

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ function Remotes.fileurl(::TestRemote, ::Any, filename, linerange)
1010
L1, L2 = first(linerange), last(linerange)
1111
return "https://github.com/JuliaBinaryWrappers/Reactant_jll.jl/$(filename)#L$(L1)-$(L2)"
1212
end
13-
Remotes.issueurl(::TestRemote, issue) = "https://github.com/EnzymeAD/Reactant.jl/blob/$(issue)"
13+
function Remotes.issueurl(::TestRemote, issue)
14+
return "https://github.com/EnzymeAD/Reactant.jl/blob/$(issue)"
15+
end
1416

1517
DocMeta.setdocmeta!(Reactant, :DocTestSetup, :(using Reactant); recursive=true)
1618

@@ -25,51 +27,66 @@ examples = Pair{String,String}[]
2527

2628
for (_, name) in examples
2729
example_filepath = joinpath(EXAMPLES_DIR, string(name, ".jl"))
28-
Literate.markdown(example_filepath, OUTPUT_DIR, documenter = true)
30+
Literate.markdown(example_filepath, OUTPUT_DIR; documenter=true)
2931
end
3032

31-
run(Cmd(`rm -rf .git`, dir=Reactant_jll.artifact_dir))
32-
run(Cmd(`git init`, dir=Reactant_jll.artifact_dir))
33-
run(Cmd(`git config user.name ReactantDocs`, dir=Reactant_jll.artifact_dir))
34-
run(Cmd(`git config user.email [email protected]`, dir=Reactant_jll.artifact_dir))
35-
run(Cmd(`git remote add origin https://github.com/EnzymeAD/Reactant.jl`, dir=Reactant_jll.artifact_dir))
36-
run(Cmd(`git add -A`, dir=Reactant_jll.artifact_dir))
37-
run(Cmd(`git commit -m "Initial commit"`, dir=Reactant_jll.artifact_dir))
33+
run(Cmd(`rm -rf .git`; dir=Reactant_jll.artifact_dir))
34+
run(Cmd(`git init`; dir=Reactant_jll.artifact_dir))
35+
run(Cmd(`git config user.name ReactantDocs`; dir=Reactant_jll.artifact_dir))
36+
run(Cmd(`git config user.email [email protected]`; dir=Reactant_jll.artifact_dir))
37+
run(
38+
Cmd(
39+
`git remote add origin https://github.com/EnzymeAD/Reactant.jl`;
40+
dir=Reactant_jll.artifact_dir,
41+
),
42+
)
43+
run(Cmd(`git add -A`; dir=Reactant_jll.artifact_dir))
44+
run(Cmd(`git commit -m "Initial commit"`; dir=Reactant_jll.artifact_dir))
3845

39-
examples = [title => joinpath("generated", string(name, ".md")) for (title, name) in examples]
46+
examples = [
47+
title => joinpath("generated", string(name, ".md")) for (title, name) in examples
48+
]
4049

4150
gh = Documenter.Remotes.GitHub("EnzymeAD", "Reactant.jl")
4251

4352
makedocs(;
44-
modules=[Reactant, Reactant.XLA, Reactant.MLIR, Reactant.MLIR.API, Reactant.MLIR.IR, Reactant.MLIR.Dialects.chlo, Reactant.MLIR.Dialects.vhlo, Reactant.MLIR.Dialects.stablehlo, Reactant.MLIR.Dialects.enzyme, Reactant.MLIR.Dialects.arith, Reactant.MLIR.Dialects.func, Reactant.MLIR.Dialects.affine, Reactant.MLIR.Dialects.builtin],
53+
modules=[
54+
Reactant,
55+
Reactant.XLA,
56+
Reactant.MLIR,
57+
Reactant.MLIR.API,
58+
Reactant.MLIR.IR,
59+
Reactant.MLIR.Dialects.chlo,
60+
Reactant.MLIR.Dialects.vhlo,
61+
Reactant.MLIR.Dialects.stablehlo,
62+
Reactant.MLIR.Dialects.enzyme,
63+
Reactant.MLIR.Dialects.arith,
64+
Reactant.MLIR.Dialects.func,
65+
Reactant.MLIR.Dialects.affine,
66+
Reactant.MLIR.Dialects.builtin,
67+
],
4568
authors="William Moses <[email protected]>, Valentin Churavy <[email protected]>",
4669
remotes=Dict(
47-
# Just non-repository directories
48-
joinpath(@__DIR__, "..") => gh,
49-
Reactant_jll.artifact_dir => TestRemote(),
70+
# Just non-repository directories
71+
joinpath(@__DIR__, "..") => gh,
72+
Reactant_jll.artifact_dir => TestRemote(),
5073
),
5174
sitename="Reactant.jl",
5275
format=Documenter.HTML(;
5376
prettyurls=get(ENV, "CI", "false") == "true",
5477
canonical="https://enzymead.github.io/Reactant.jl/",
55-
size_threshold_ignore = ["api.md"],
56-
assets = [
57-
asset("https://plausible.io/js/plausible.js",
58-
class=:js,
59-
attributes=Dict(Symbol("data-domain") => "enzyme.mit.edu", :defer => "")
60-
)
61-
],
78+
size_threshold_ignore=["api.md"],
79+
assets=[
80+
asset(
81+
"https://plausible.io/js/plausible.js";
82+
class=:js,
83+
attributes=Dict(Symbol("data-domain") => "enzyme.mit.edu", :defer => ""),
84+
),
85+
],
6286
),
63-
pages = [
64-
"Home" => "index.md",
65-
"API reference" => "api.md",
66-
],
67-
doctest = true,
68-
warnonly = true,
87+
pages=["Home" => "index.md", "API reference" => "api.md"],
88+
doctest=true,
89+
warnonly=true,
6990
)
7091

71-
deploydocs(;
72-
repo="github.com/EnzymeAD/Reactant.jl",
73-
devbranch = "main",
74-
push_preview = true,
75-
)
92+
deploydocs(; repo="github.com/EnzymeAD/Reactant.jl", devbranch="main", push_preview=true)

0 commit comments

Comments
 (0)