Skip to content

Closes #3568: Update flatten_benchmark - #4611

Merged
ajpotts merged 1 commit into
Bears-R-Us:masterfrom
ajpotts:3568_Update_flatten_benchmark
Jul 8, 2025
Merged

ajpotts merged 1 commit into
Bears-R-Us:masterfrom
ajpotts:3568_Update_flatten_benchmark

Conversation

@ajpotts

@ajpotts ajpotts commented Jun 13, 2025 •

Copy link
Copy Markdown
Contributor

PR: Add flatten Benchmark to Mimic NumPy's flatten Behavior

This PR introduces a new benchmark for ak.flatten that mimics the behavior of np.flatten, i.e., flattening a reshaped 2D array into 1D.

✅ Key Features

  • NumPy-Style Flattening

    • Benchmarks ak.flatten on a reshaped (M, N) 2D array created from a 1D Arkouda array.
    • Matches the semantic behavior of np.flatten().
  • Supports Multiple Dtypes

    • Tests across int64, float64, and bool dtypes.
  • Correctness Verification (--correctness_only)

    • Validates that the Arkouda flatten result matches np.flatten() using np.testing.assert_array_equal.
  • Scalable Benchmarking

    • Reduces problem size to 10**4 when --correctness_only is used.
    • Uses pedantic(...) with transfer rate calculation in GiB/sec.

🧪 Benchmark Group

Benchmarks are grouped under:

@benchmark(group="AK_flatten")

@ajpotts
ajpotts force-pushed the 3568_Update_flatten_benchmark branch 6 times, most recently from bfa0eb8 to 83d8c5f Compare June 20, 2025 17:19
@ajpotts
ajpotts marked this pull request as ready for review June 20, 2025 18:45
@ajpotts
ajpotts requested a review from vasslitvinov June 25, 2025 15:54

@1RyanK 1RyanK left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good! I suspect the current flatten will work well on (2, N // 2), decently on square, and probably not that well on the other.

Comment thread benchmark_v2/flatten_benchmark.py Resolved
@ajpotts
ajpotts force-pushed the 3568_Update_flatten_benchmark branch from 83d8c5f to 6e14164 Compare June 30, 2025 15:50
@ajpotts ajpotts added the blocking This is blocking a developer from completing a task they are actively working. label Jul 1, 2025
Comment thread benchmark_v2/conftest.py Resolved
@ajpotts
ajpotts force-pushed the 3568_Update_flatten_benchmark branch from 6e14164 to c9e7fcc Compare July 7, 2025 13:50
Comment thread benchmark_v2/flatten_benchmark.py Resolved
Comment thread benchmark_v2/flatten_benchmark.py Resolved
Comment thread benchmark_v2/flatten_benchmark.py Resolved

@vasslitvinov vasslitvinov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would like to double-check that producing the test data arr2d using reshape is adequate. In other words, ensure that reshape does not create a peculiar internal representation for the array that 2-d arrays would usually not have, therefore skewing performance results.

@ajpotts
ajpotts force-pushed the 3568_Update_flatten_benchmark branch from c9e7fcc to e4741c3 Compare July 8, 2025 13:40
@ajpotts
ajpotts enabled auto-merge July 8, 2025 18:15
@ajpotts
ajpotts added this pull request to the merge queue Jul 8, 2025
Merged via the queue into Bears-R-Us:master with commit de9b32e Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocking This is blocking a developer from completing a task they are actively working.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants