You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2017/10/19 05:02:17 UTC
[GitHub] reminisce commented on a change in pull request #8340: Fill optimizations
reminisce commented on a change in pull request #8340: Fill optimizations
URL: https://github.com/apache/incubator-mxnet/pull/8340#discussion_r145599999
##########
File path: src/operator/tensor/init_op.h
##########
@@ -164,19 +164,38 @@ inline bool InitStorageType(const nnvm::NodeAttrs& attrs,
return true;
}
+/*! \brief Fill output with a scalar integer value */
template<typename xpu, int value>
void FillCompute(const nnvm::NodeAttrs& attrs,
const OpContext& ctx,
const std::vector<TBlob>& inputs,
const std::vector<OpReqType>& req,
const std::vector<TBlob>& outputs) {
- using namespace mshadow;
- using namespace mshadow::expr;
- Stream<xpu> *s = ctx.get_stream<xpu>();
- MSHADOW_TYPE_SWITCH(outputs[0].type_flag_, DType, {
- Tensor<xpu, 1, DType> out = outputs[0].FlatTo1D<xpu, DType>(s);
- ASSIGN_DISPATCH(out, req[0], scalar<DType>(value));
- });
+ if (req[0] != kNullOp) {
+ mshadow::Stream<xpu> *s = ctx.get_stream<xpu>();
+ MSHADOW_TYPE_SWITCH(outputs[0].type_flag_, DType, {
+ mxnet_op::Kernel<mxnet_op::set_to<value>, xpu>::Launch(s,
Review comment:
What if `req[0]` is `kAddTo`?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services