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 2019/02/13 00:05:20 UTC

[GitHub] leleamol commented on issue #14129: NDArray C++ construct problem

leleamol commented on issue #14129: NDArray C++	construct problem 
URL: https://github.com/apache/incubator-mxnet/issues/14129#issuecomment-462996013
 
 
   @songziqin ,
   
   The implementation of constructors NDAarray(const vector<mx_float>&data) and NDArray(const mx_float* data) in c++ API (cpp-package/include/mxnet-cpp/ndarray.h) is incorrect.  These constructors call MXNDArrayCreateNone() API that creates an empty NDArrayHandle which is uninitialized. In order to create and store data in an NDArray object successfully, we need to have the context (cpu or gpu) and shape dimensions.
   
   We should remove these constructors as they are not very helpful and incorrectly implemented.
   
   The right way to initialize the above NDArray is as follows:
   
   `NDArray nd_array(v, Shape(v.size(), 1), Context::cpu());
   `
   
   I hope this helps.

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