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

[MXNET-853] Fix for smooth_l1 operator scalar default value #12284

Merged
merged 5 commits into from
Sep 10, 2018

Conversation

samskalicky
Copy link
Contributor

@samskalicky samskalicky commented Aug 21, 2018

Description

Fix for issue #7533 Call symbol/nd.smooth_l1 without scalar causing uncaught exception

changed smooth_l1 operator implementation to not use helper macros since
they do not provide enough support for checking for arguments and
setting custom default values

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • 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
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

changed smooth_l1 operator implementation to not use helper macros since
they do not provide enough support for checking for arguments and
setting custom default values

Comments

@zhreshold
Copy link
Member

It should properly catch the exception anyway, rather than assigning every single operator a default value

.set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseIn{ "_backward_smooth_l1" });

Copy link
Contributor

Choose a reason for hiding this comment

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

Why extra 2 blank spaces here?

.set_attr<nnvm::FInplaceOption>("FInplaceOption",
[](const NodeAttrs& attrs){
return std::vector<std::pair<int, int> >{{0, 0}};
})
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like you're using tabs here, please switch to spaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, new editor not setup properly....

Copy link
Contributor

@haojin2 haojin2 left a comment

Choose a reason for hiding this comment

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

@samskalicky
Copy link
Contributor Author

@haojin2 linting fixed
@zhreshold Is catching the exception what we want to do? What should we do after catching the exception? Set the default value? If we dont set something, its just going to error out somewhere further down the line. It seems to me that this is actually a larger and more in-depth problem than it initially appears so ive filed another issue to track that specifically #12286. But fixing that is going require a little more planning. What is the minimum acceptable behavior for this operator to close this issue?

@zhreshold
Copy link
Member

@samskalicky I didn't mean not sending this PR to fix the problem, but should address the exception catch problem anyways. Sorry about the confusion. #12286 is a perfect attempt. Thanks!

This LGTM now.

@samskalicky
Copy link
Contributor Author

@anirudh2290 can you help review/merge?

Copy link
Member

@anirudh2290 anirudh2290 left a comment

Choose a reason for hiding this comment

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

LGTM. In future, we would want to add a dmlc::Parameter for ops like smooth_l1. This would help with improvement of operator documentation too. Currently the default value won't get documented.

@samskalicky
Copy link
Contributor Author

@anirudh2290 fixed syntax to match mxnet style (curly braces). This change is now ready for merging

@anirudh2290 anirudh2290 merged commit c8c3b04 into apache:master Sep 10, 2018
aaronmarkham pushed a commit to aaronmarkham/incubator-mxnet that referenced this pull request Sep 11, 2018
…2284)

* changed smooth_l1 operator implementation to not use helper macros since
they do not provide enough support for checking for arguments and
setting custom default values

* added testcase for smooth_l1 operator scalar default value

* fixed whitespace

* added curly braces for if/else to match mxnet style

* added more curly braces
anirudh2290 pushed a commit to anirudh2290/mxnet that referenced this pull request Sep 19, 2018
…2284)

* changed smooth_l1 operator implementation to not use helper macros since
they do not provide enough support for checking for arguments and
setting custom default values

* added testcase for smooth_l1 operator scalar default value

* fixed whitespace

* added curly braces for if/else to match mxnet style

* added more curly braces
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.

4 participants