anirudh2290 commented on a change in pull request #14830: [WIP] Use env var to
enforce safe accumulation in ReduceAxesCompute
URL: https://github.com/apache/incubator-mxnet/pull/14830#discussion_r280963980
##########
File path: src/operator/tensor/broadcast_reduce_op.h
##########
@@ -1183,12 +1183,23 @@ void LpNormCompute(const nnvm::NodeAttrs& attrs,
} else {
small = ReduceAxesShapeImpl(inputs[0].shape_, param.axis, true, false);
}
+
if (param.ord == 1) {
- ReduceAxesComputeImpl<xpu, mshadow_op::sum, true, false, mshadow_op::abs>(
+ if (dmlc::GetEnv("MXNET_ENFORCE_SAFE_ACCUMULATION", false)) {
+ ReduceAxesComputeImpl<xpu, mshadow_op::sum, true, false,
mshadow_op::abs>(
+ ctx, inputs, req, outputs, small);
+ } else {
+ ReduceAxesComputeImpl<xpu, mshadow_op::sum, false, false,
mshadow_op::abs>(
ctx, inputs, req, outputs, small);
+ }
} else if (param.ord == 2) {
- ReduceAxesComputeImpl<xpu, mshadow_op::nrm2, true, false,
mshadow_op::identity>(
+ if (dmlc::GetEnv("MXNET_ENFORCE_SAFE_ACCUMULATION", false)) {
Review comment:
Here is what I understand from the PRs: #14616 and #14098: when out_dtype is
provided safe_accumulation is then set, to produce output of out_dtype and
accumulation of next higher precision dtype (or accumulate in fp64 if out_dtype
is fp64). For example, if out_dtype is provided as fp32, accumulation is done
in fp64, if out_dtype is provided as uint8, accumulation is done in uint32. If
my understanding is correct, if out_dtype is provided as fp16, accumulation
will be done in fp32. Isn't this what you expect ? What is the burden here ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services