I am changing an c++ example in mxnet. I do not understand how to allocate an NDArray object. There is no even basic documentation around, which is pretty frustrating.
I try to allocate an NDArray, but by declaring an instance it does not seem to allocate the data, only when I fill an array with data. Is that correct?
// this code snippet does not work
NDArray a = NDArray(Shape(10, 20), Context::cpu());
const float *dat = a.GetData();
float result = *dat; // read memory violation
result = *(dat + 10);
// this code snippet works
NDArray b = NDArray(Shape(10, 20), Context::cpu());
a.SampleUniform(1.0, 2.0, &b);
const float *dat2 = b.GetData();
float result2 = *dat2; // works!!
result2 = *(dat2 + 10);
Has someone experience with the c++ API and changing networks?