wuxun-zhang commented on a change in pull request #15697: Fix dropout mask 
output when built with MKL
URL: https://github.com/apache/incubator-mxnet/pull/15697#discussion_r310375521
 
 

 ##########
 File path: src/operator/nn/dropout-inl.h
 ##########
 @@ -130,11 +130,18 @@ class DropoutOp {
     DType *dataptr = data.dptr_;
     auto maskptr = reinterpret_cast<int *>(mask.dptr_);
     int count = mask.shape_[0] * mask.shape_[1];
+    if (sizeof(DType) > sizeof(int)) {
+      // allocating new buffer to avoiding memory overlapping between 
`mask.dptr_` and `maskptr`
+      Tensor<xpu, 1, int> temp = ctx.requested[1].get_space_typed<xpu, 1, 
int>(Shape1(count), s);
+      maskptr = temp.dptr_;
 
 Review comment:
   Seems will not be deleted. I put it here mainly because `mask` buffer can 
not be reused when `sizeof(DType) > sizeof(int)` and must allocate new memory 
space to avoid memory overlapping. 

----------------------------------------------------------------
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

Reply via email to