Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Conversation

@Ldpe2G
Copy link
Contributor

@Ldpe2G Ldpe2G commented Mar 4, 2018

Description

add a function to c_predict_api which can change the input shape of an already created predicator .
related issue: #5360

Checklist

Essentials

  • Passed code style checking (make lint)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Feature1, tests, (and when applicable, API doc)
  • Feature2, tests, (and when applicable, API doc)

Comments

  • If this change is a backward incompatible change, why must this change be made.
  • Interesting edge cases to note here

@Ldpe2G Ldpe2G requested a review from cjolivier01 as a code owner March 4, 2018 08:41
PredictorHandle* out) {
MXAPIPredictor* p = static_cast<MXAPIPredictor*>(handle);
MXAPIPredictor* ret = new MXAPIPredictor();

Copy link
Member

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,
Copy link
Member

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?

Copy link
Contributor Author

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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use reserve()?

// bind
{
std::map<std::string, Context> ctx_map;
std::vector<NDArray> grad_store(ret->arg_arrays.size());
Copy link
Member

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)

@CodingCat
Copy link
Contributor

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!

@Ldpe2G Ldpe2G changed the title add reshape predicator function to c_predict_api [MXNET-38]add reshape predicator function to c_predict_api Mar 7, 2018
@Ldpe2G
Copy link
Contributor Author

Ldpe2G commented Mar 7, 2018

@cjolivier01 I have updated the pr

@Ldpe2G
Copy link
Contributor Author

Ldpe2G commented Mar 10, 2018

@cjolivier01 can this pr be merge?

@cjolivier01 cjolivier01 merged commit 1794a2a into apache:master Mar 10, 2018
jinhuang415 pushed a commit to jinhuang415/incubator-mxnet that referenced this pull request Mar 30, 2018
* add reshape predicator function to c_predict_api

* fix

* fix

* fix
rahul003 pushed a commit to rahul003/mxnet that referenced this pull request Jun 4, 2018
* add reshape predicator function to c_predict_api

* fix

* fix

* fix
zheng-da pushed a commit to zheng-da/incubator-mxnet that referenced this pull request Jun 28, 2018
* add reshape predicator function to c_predict_api

* fix

* fix

* fix
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants