[GitHub] asitstands commented on a change in pull request #10970: [MXNET-424] dtype option for multinomial

2018-05-30 Thread GitBox
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_r191984961
 
 

 ##
 File path: src/operator/random/sample_multinomial_op.h
 ##
 @@ -67,6 +70,10 @@ inline bool SampleMultinomialOpShape(const nnvm::NodeAttrs& 
attrs,
   const TShape& ishape = (*in_attrs)[0];
   if (!ishape.ndim()) return false;
 
+  MSHADOW_TYPE_SWITCH(param.dtype, DType, {
+CHECK_LE(ishape[ishape.ndim() - 1], 
mxnet::common::MaxIntegerValue());
 
 Review comment:
   I added an error message.


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


[GitHub] asitstands commented on a change in pull request #10970: [MXNET-424] dtype option for multinomial

2018-05-17 Thread GitBox
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 uniform =
   ctx.requested[1].get_space_typed(Shape1(N*M), s);
 prnd->SampleUniform(&uniform, 0, 1);
-Kernel::Launch(
-  s, N, K, M, inputs[0].dptr(), uniform.dptr_, 
outputs[0].dptr(),
-  param.get_prob ? outputs[1].dptr() : 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


[GitHub] asitstands commented on a change in pull request #10970: [MXNET-424] dtype option for multinomial

2018-05-17 Thread GitBox
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 uniform =
   ctx.requested[1].get_space_typed(Shape1(N*M), s);
 prnd->SampleUniform(&uniform, 0, 1);
-Kernel::Launch(
-  s, N, K, M, inputs[0].dptr(), uniform.dptr_, 
outputs[0].dptr(),
-  param.get_prob ? outputs[1].dptr() : 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 which slow 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