Skip to content

Commit ee947fa

Browse files
Decompositions for reduceLogSum, reduceLogSumExp, and reduceSumSquare (#637)
* Decompositions for reduceLogSum, reduceLogSumExp, and reduceSumSquare As noted in #209, not all frameworks/platform APIs support all reduce operations, but these are easily emulated. Decompositions are provided using the standard phrasing and style currently used throughout the spec. In the future, we may alter the wording to explicitly state that these decompositions can be used as templates for implementations to follow when their underlying frameworks/platform APIs do not support the operations. Fixes #209 * Update index.bs Co-authored-by: Ningxin Hu <[email protected]> --------- Co-authored-by: Ningxin Hu <[email protected]>
1 parent 9cb4125 commit ee947fa

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

index.bs

+21
Original file line numberDiff line numberDiff line change
@@ -4929,6 +4929,27 @@ partial interface MLGraphBuilder {
49294929
</div>
49304930
</details>
49314931

4932+
<div class="note">
4933+
<details open>
4934+
<summary>
4935+
The behavior of several reduction operations can be generically emulated from the usage of
4936+
other operations as follows. However, user agents typically have a more
4937+
efficient implementation for them, therefore their usage is encouraged from the
4938+
performance standpoint.
4939+
</summary>
4940+
<pre highlight="js">
4941+
// reduceLogSum(input, options)
4942+
return builder.log(builder.reduceSum(input, options));
4943+
4944+
// reduceLogSumExp(input, options)
4945+
return builder.log(builder.reduceSum(builder.exp(input), options));
4946+
4947+
// reduceSumSquare(input, options)
4948+
return builder.reduceSum(builder.pow(input, 2), options);
4949+
</pre>
4950+
</details>
4951+
</div>
4952+
49324953
### relu ### {#api-mlgraphbuilder-relu-method}
49334954
Compute the <a href="https://en.wikipedia.org/wiki/Rectifier_(neural_networks)">rectified linear function</a> of the input tensor.
49344955

0 commit comments

Comments
 (0)