Skip to content

Handle case in EnzymeTestUtils of reduction over empties#3131

Merged
wsmoses merged 4 commits into
mainfrom
ksh/empty_ydots
Jun 4, 2026
Merged

Handle case in EnzymeTestUtils of reduction over empties#3131
wsmoses merged 4 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 87d6f707..11f89564 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) ? similar(x, 0) : transpose(reduce(hcat, ẏs))
+    mat = isempty(ẏs) ? similar(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 b283e0c... main / b283e0c...
basics/make_zero/namedtuple 0.0519 ± 0.0016 μs 0.0521 ± 0.0012 μs 0.995 ± 0.038
basics/make_zero/struct 0.264 ± 0.0054 μs 0.265 ± 0.0058 μs 0.996 ± 0.03
basics/overhead 5.87 ± 0.92 ns 4.33 ± 0.01 ns 1.36 ± 0.21
basics/remake_zero!/namedtuple 0.23 ± 0.0091 μs 0.231 ± 0.0078 μs 0.996 ± 0.052
basics/remake_zero!/struct 0.236 ± 0.0071 μs 0.225 ± 0.007 μs 1.05 ± 0.045
fold_broadcast/multidim_sum_bcast/1D 10.2 ± 0.22 μs 10.2 ± 0.26 μs 1 ± 0.034
fold_broadcast/multidim_sum_bcast/2D 12.1 ± 0.22 μs 12.1 ± 0.23 μs 1 ± 0.026
time_to_load 1.02 ± 0.0042 s 1.03 ± 0.0064 s 0.991 ± 0.0074

Benchmark Plots

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

@kshyatt kshyatt force-pushed the ksh/empty_ydots branch from 0ba9088 to 7a7cecf Compare May 29, 2026 05:36
Comment thread lib/EnzymeTestUtils/src/finite_difference_calls.jl Outdated
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?

@wsmoses
Copy link
Copy Markdown
Member

wsmoses commented Jun 2, 2026

basic gist is that if you hit this in your real code, if we don't test it -- there's a chance the functionality is reverted accidentally. so anything that exercises that

@kshyatt
Copy link
Copy Markdown
Collaborator Author

kshyatt commented Jun 2, 2026

Yeah I'm aware of how tests work lol, I'm just trying to find a good case because clearly this is a weird edge scenario

@wsmoses
Copy link
Copy Markdown
Member

wsmoses commented Jun 2, 2026

ah yeah fair

@kshyatt
Copy link
Copy Markdown
Collaborator Author

kshyatt commented Jun 2, 2026

Need to engage my "goofball test case generator" powers again...

@kshyatt kshyatt force-pushed the ksh/empty_ydots branch from 6d61938 to b283e0c Compare June 3, 2026 07:23
@wsmoses wsmoses merged commit 55da844 into main Jun 4, 2026
59 of 70 checks passed
@wsmoses wsmoses deleted the ksh/empty_ydots branch June 4, 2026 01:52
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