dabraude commented on a change in pull request #9883: added function for loading content of nd_array files URL: https://github.com/apache/incubator-mxnet/pull/9883#discussion_r170463743
########## File path: src/c_api/c_api.cc ########## @@ -322,6 +322,38 @@ int MXNDArrayLoad(const char* fname, API_END(); } +int MXNDArrayLoadFileContent(const void *nd_file, + size_t size, + mx_uint *out_size, + NDArrayHandle** out_arr, + mx_uint *out_name_size, + const char*** out_names) { + MXAPIThreadLocalEntry *ret = MXAPIThreadLocalStore::Get(); + ret->ret_vec_str.clear(); + API_BEGIN(); + std::vector<NDArray> data; + std::vector<std::string> &names = ret->ret_vec_str; + { + std::unique_ptr<dmlc::MemoryFixedSizeStream> fi(new dmlc::MemoryFixedSizeStream((void*)nd_file, size)); // NOLINT(*) + mxnet::NDArray::Load(fi.get(), &data, &names); Review comment: Just checked multiple versions of this, it will return -1 with the last error message being: `Check failed: header == kMXAPINDArrayListMagic Invalid NDArray file format` Python can check for that pretty easily. Just added a check against NULL pointers which I didn't think of originally. ---------------------------------------------------------------- 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