asitstands commented on a change in pull request #10970: [MXNET-424] dtype 
option for multinomial
URL: https://github.com/apache/incubator-mxnet/pull/10970#discussion_r189154689
 
 

 ##########
 File path: src/operator/random/sample_multinomial_op.h
 ##########
 @@ -155,9 +158,11 @@ void SampleMultinomialForward(const nnvm::NodeAttrs& 
attrs,
     Tensor<xpu, 1, float> uniform =
       ctx.requested[1].get_space_typed<xpu, 1, float>(Shape1(N*M), s);
     prnd->SampleUniform(&uniform, 0, 1);
-    Kernel<SampleMultinomialKernel, xpu>::Launch(
-      s, N, K, M, inputs[0].dptr<DType>(), uniform.dptr_, 
outputs[0].dptr<int>(),
-      param.get_prob ? outputs[1].dptr<DType>() : nullptr);
+    MSHADOW_TYPE_SWITCH(outputs[0].type_flag_, IType, {
 
 Review comment:
   Sometimes the multinomial samples need further processing in floating point 
arithmetic, so the samples need to be copied into a new array of floating point 
type. The copy slows down the training. For example, in RBM, the samples need 
to be applied by `linalg.gemm` which supports only floating point arrays.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to