-
Notifications
You must be signed in to change notification settings - Fork 6.7k
[MXNET-38]add reshape predicator function to c_predict_api #9984
Conversation
| PredictorHandle* out) { | ||
| MXAPIPredictor* p = static_cast<MXAPIPredictor*>(handle); | ||
| MXAPIPredictor* ret = new MXAPIPredictor(); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please wrap with unique_ptr and then if all is successful, assign with the result of .release()
| API_END_HANDLE_ERROR(delete ret); | ||
| } | ||
|
|
||
| int MXPredReshape(mx_uint num_input_nodes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when does this get called? during training or during setup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
during testing, when you need to change the input shape of an already created predicator.
| ret->key2arg = p->key2arg; | ||
|
|
||
| try { | ||
| std::vector<TShape> in_shapes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you use reserve()?
src/c_api/c_predict_api.cc
Outdated
| // bind | ||
| { | ||
| std::map<std::string, Context> ctx_map; | ||
| std::vector<NDArray> grad_store(ret->arg_arrays.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this and other places, defining to a size causes all of the constructors to be called. if the item is simply overwritten shortly after (ie the init item is just a placeholder), then it is more efficient (sometimes by a lot) to create an empty vector, call reserve() for the number of desired items, and then use emplace_back() (or push_back() if emplace can’t be called)
|
Hi, the community has passed to vote about associating the code changes with JIRA (https://lists.apache.org/thread.html/ab22cf0e35f1bce2c3bf3bec2bc5b85a9583a3fe7fd56ba1bbade55f@%3Cdev.mxnet.apache.org%3E) We have updated the guidelines for contributors in https://cwiki.apache.org/confluence/display/MXNET/Development+Process, please ensure that you have created a JIRA at https://issues.apache.org/jira/projects/MXNET/issues/ to describe your work in this pull request and include the JIRA title in your PR as [MXNET-xxxx] your title where MXNET-xxxx is the JIRA id Thanks! |
|
@cjolivier01 I have updated the pr |
|
@cjolivier01 can this pr be merge? |
* add reshape predicator function to c_predict_api * fix * fix * fix
* add reshape predicator function to c_predict_api * fix * fix * fix
* add reshape predicator function to c_predict_api * fix * fix * fix
Description
add a function to c_predict_api which can change the input shape of an already created predicator .
related issue: #5360
Checklist
Essentials
make lint)Changes
Comments