ZhennanQin commented on issue #13581: Inplace Reshape? URL: https://github.com/apache/incubator-mxnet/issues/13581#issuecomment-446795859 @Jerryzcn What do you mean by `not work properly`? If you are referring the performance doesn't improve with `F.reshape(x, (shape), out=x)`, it's true, because `UnaryOp::IdentityCompute<cpu>` will do copy even if inplace happens. To fix this, you can add a check in `mxnet_op::copy` to skip the memory copy when src and dst have same address, which indicates inplace happens. https://github.com/apache/incubator-mxnet/blob/49e6a7e40691936e533f7cf16848b10c025e4e75/src/operator/mxnet_op.h#L398 PS: With above fix, you don't need to make inplace happen manually with `F.reshape(x, (shape), out=x)`, `F.reshape(x, (shape), out=y)` should work as well.
---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
