Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PrecompileTools #18

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ authors = ["Anton Smirnov <tonysmn97@gmail.com>"]
version = "0.1.4"

[deps]
AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e"
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
GPUCompiler = "61eb1bfa-7361-4325-ad38-22787b887f55"
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
ImageTransformations = "02fcd773-0e25-5acc-982a-7f6622650795"
Expand All @@ -19,6 +19,7 @@ JpegTurbo = "b835a17e-a41a-41e7-81f0-2f016b05efe0"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
NerfUtils = "99c1d5ce-7c61-4a25-a107-a5ade2e2a8e4"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Quaternions = "94ee1d12-ae83-5a48-8b1c-48b8ff168ae0"
Rotations = "6038ab10-8711-5258-84ad-4b1120ba62dc"
Expand All @@ -27,7 +28,6 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[compat]
AMDGPU = "0.8"
Adapt = "4"
BSON = "0.3"
BenchmarkTools = "1.3.2"
Expand All @@ -41,6 +41,7 @@ JSON = "0.21"
JpegTurbo = "0.1"
KernelAbstractions = "0.9"
NerfUtils = "0.1.5"
PrecompileTools = "1.2.1"
Preferences = "1.4"
Quaternions = "0.7"
Rotations = "1.6"
Expand Down
2 changes: 0 additions & 2 deletions benchmark/pipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ const Backend = Nerf.Backend

function trainer_benchmark(trainer::Nerf.Trainer, n::Int)
for i in 1:n
Core.println(i)
Nerf.step!(trainer)
end
end

function render_benchmark(renderer::Nerf.Renderer, trainer::Nerf.Trainer, n::Int)
for i in 1:n
Core.println(i)
Nerf.render!(trainer.model, renderer, trainer.occupancy, trainer.bbox)
end
end
Expand Down
24 changes: 24 additions & 0 deletions src/Nerf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,28 @@ function main()
return
end

using PrecompileTools

@setup_workload let
config_file = joinpath(pkgdir(Nerf), "data", "raccoon_sofa2", "transforms.json")
dataset = Dataset(Backend; config_file)
model = BasicModel(BasicField(Backend))

trainer = Trainer(model, dataset; n_rays=128)
camera = Camera(MMatrix{3, 4, Float32}(I), dataset.intrinsics)
renderer = Renderer(Backend, camera, trainer.bbox, trainer.cone)

pose_idx = clamp(round(Int, rand() * length(dataset)), 1, length(dataset))
NU.set_projection!(camera, get_pose(dataset, pose_idx)...)

@compile_workload begin
for _ in 1:20
step!(trainer)
end
render!(renderer, trainer.occupancy, trainer.bbox) do points, directions
model(points, directions)
end
end
end

end
2 changes: 1 addition & 1 deletion src/kautils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function is_valid_backend(name::String)
""")
end

backend_name() = is_valid_backend(@load_preference("backend", "AMDGPU"))
backend_name() = is_valid_backend(@load_preference("backend", "CUDA"))

function set_backend!(name::String)::Bool
backend_name() == name && return false
Expand Down
Loading