Skip to content

Handle case in EnzymeTestUtils of reduction over empties#3131

Open
kshyatt wants to merge 2 commits into
mainfrom
ksh/empty_ydots
Open

Handle case in EnzymeTestUtils of reduction over empties#3131
kshyatt wants to merge 2 commits into
mainfrom
ksh/empty_ydots

Conversation

@kshyatt
Copy link
Copy Markdown
Collaborator

@kshyatt kshyatt commented May 28, 2026

This keeps screwing up my life!!!!

@kshyatt kshyatt requested a review from wsmoses May 28, 2026 14:35
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 28, 2026

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic main) to apply these changes.

Click here to view the suggested changes.
diff --git a/lib/EnzymeTestUtils/src/finite_difference_calls.jl b/lib/EnzymeTestUtils/src/finite_difference_calls.jl
index d6fe9026..9e355106 100644
--- a/lib/EnzymeTestUtils/src/finite_difference_calls.jl
+++ b/lib/EnzymeTestUtils/src/finite_difference_calls.jl
@@ -71,7 +71,7 @@ function j′vp(fdm, f_vec, ȳ, x)
         end
     end
   end
-  mat = isempty(ẏs) ? zeros(x, 0) : transpose(reduce(hcat, ẏs))
+    mat = isempty(ẏs) ? zeros(x, 0) : transpose(reduce(hcat, ẏs))
   result = zero(x)
   for i in 1:length(ȳ)
     tp = @inbounds ȳ[i] 

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 28, 2026

Benchmark Results

main cee6699... main / cee6699...
basics/make_zero/namedtuple 0.0613 ± 0.0054 μs 0.0617 ± 0.005 μs 0.994 ± 0.12
basics/make_zero/struct 0.261 ± 0.01 μs 0.263 ± 0.011 μs 0.992 ± 0.055
basics/overhead 4.88 ± 0.01 ns 5.23 ± 0 ns 0.933 ± 0.0019
basics/remake_zero!/namedtuple 0.234 ± 0.013 μs 0.234 ± 0.011 μs 1 ± 0.072
basics/remake_zero!/struct 0.232 ± 0.014 μs 0.233 ± 0.01 μs 0.996 ± 0.075
fold_broadcast/multidim_sum_bcast/1D 10.5 ± 2.2 μs 10.5 ± 0.36 μs 1 ± 0.21
fold_broadcast/multidim_sum_bcast/2D 12.8 ± 0.44 μs 12.8 ± 0.45 μs 0.999 ± 0.049
time_to_load 1.18 ± 0.028 s 1.15 ± 0.00069 s 1.03 ± 0.024

Benchmark Plots

A plot of the benchmark results has been uploaded as an artifact at https://github.com/EnzymeAD/Enzyme.jl/actions/runs/26741441976/artifacts/7325909088.

@kshyatt kshyatt force-pushed the ksh/empty_ydots branch from 0ba9088 to 7a7cecf Compare May 29, 2026 05:36
end
end
mat = transpose(reduce(hcat, ẏs))
mat = isempty(ẏs) ? [] : transpose(reduce(hcat, ẏs))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be better to have it be similar or zeros of x or something, to keep the type?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that could work, I'll try it out!

Copy link
Copy Markdown
Member

@wsmoses wsmoses left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a test?

@kshyatt
Copy link
Copy Markdown
Collaborator Author

kshyatt commented Jun 1, 2026

add a test?

I'd love to but it's kind of annoying because this function is only tested implicitly by other stuff... I'll see if I can think of a good way to do it. Or do you mind if I just call it directly in a test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants