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 2018/02/01 16:41:55 UTC
[GitHub] cjolivier01 commented on a change in pull request #9573: Added two functions to the C API
cjolivier01 commented on a change in pull request #9573: Added two functions to the C API
URL: https://github.com/apache/incubator-mxnet/pull/9573#discussion_r165413568
##########
File path: src/c_api/c_api.cc
##########
@@ -358,6 +364,38 @@ int MXNDArrayLoad(const char* fname,
API_END();
}
+int MXNDArrayLoadListFromMemory(const void *buf,
+ 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*)buf, size)); // NOLINT(*)
+ mxnet::NDArray::Load(fi.get(), &data, &names);
+ }
+ ret->ret_handles.resize(data.size());
+ for (size_t i = 0; i < data.size(); ++i) {
+ NDArray *ptr = new NDArray();
+ *ptr = data[i];
Review comment:
Looks like you immediately reassign 'ptr' and leak the newly created NDArray?
----------------------------------------------------------------
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