Skip to content

Commit

Permalink
Link broadcast and reduce-axis to each other (#19)
Browse files Browse the repository at this point in the history
to improve discoverability.
  • Loading branch information
holyjak committed Mar 16, 2021
1 parent 3eb000f commit 652ff50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/tech/v3/datatype/base.clj
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,9 @@ user> (dtt/transpose tensor [1 2 0])

(defn broadcast
"Broadcase an element into a new (larger) shape. The new shape's dimension
must be even multiples of the old shape's dimensions. Elements are repeated."
must be even multiples of the old shape's dimensions. Elements are repeated.
See [[reduce-axis]] for the opposite operation."
^NDBuffer [t new-shape]
(check-ns 'tech.v3.tensor)
(dtype-proto/broadcast t new-shape))
Expand Down
4 changes: 3 additions & 1 deletion src/tech/v3/tensor.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,9 @@ user> (dtype/shape (dtt/reduce-axis dfn/sum t 1))
[2 5]
user> (dtype/shape (dtt/reduce-axis dfn/sum t 2))
[2 3]
```"
```
For the opposite - adding dimensions via repetition - see [[broadcast]]."
([reduce-fn tensor axis res-dtype]
(let [rank (count (dtype-base/shape tensor))
dec-rank (dec rank)
Expand Down

0 comments on commit 652ff50

Please sign in to comment.