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

[Breaking] Redesign broadcasts/reductions to enable multi axis reductions #190

Merged
merged 22 commits into from
Sep 28, 2022

Conversation

coreylowman
Copy link
Owner

@coreylowman coreylowman commented Sep 25, 2022

Progress on #163
Progress on #191

Breaking Changes

  • Add trait Broadcast and Broadcast::broadcast()
    • Remove trait Broadcast1, trait Broadcast2, trait Broadcast3, trait Broadcast4
    • Remove .broadcast2(), .broadcast2(), .broadcast3(), .broadcast4()
  • Add trait Reduce
    • Remove trait Reduce1

Description

Turned out to be really annoying to implement with the previous approach.

Summary:

  • Add private BroadcastRef and BroadcastMut
  • Add private IndexRef and IndexMut
  • Add Accumulator
  • Combine device broadcast & reduce into 1 trait DeviceReduce
  • Combine tensor broadcast & reduce into 2 traits Broadcast and Reduce

Broadcast and reduce are very much opposites of each other. They share the exact same behavior but with the direction reversed. The new method works by always broadcasting the smaller array to a bigger one using the new BroadcastRef/Mut. By implementing ElementRef/Mut for both the BroadcastRef/Mut structs and raw arrays, you can just treat broadcast/reduce as a normal element-wise operation.

@coreylowman coreylowman marked this pull request as draft September 25, 2022 19:19
@coreylowman coreylowman added the breaking-change Semver breaking change label Sep 26, 2022
@coreylowman coreylowman changed the title WIP: Redesign broadcasts/reductions to allow reductions across multiple axes WIP: [Breaking] Redesign broadcasts/reductions to allow reductions across multiple axes Sep 26, 2022
src/devices/mod.rs Outdated Show resolved Hide resolved
@coreylowman coreylowman changed the title WIP: [Breaking] Redesign broadcasts/reductions to allow reductions across multiple axes [Breaking] Redesign broadcasts/reductions to allow reductions across multiple axes Sep 28, 2022
@coreylowman coreylowman marked this pull request as ready for review September 28, 2022 12:07
@coreylowman coreylowman changed the title [Breaking] Redesign broadcasts/reductions to allow reductions across multiple axes [Breaking] Redesign broadcasts/reductions to enable multi axis reductions Sep 28, 2022
@coreylowman coreylowman merged commit 86dbb77 into main Sep 28, 2022
@coreylowman coreylowman deleted the multi-reduce branch September 28, 2022 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Semver breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant