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

Support destructors for custom stateful ops #19607

Merged
merged 6 commits into from
Dec 4, 2020

Conversation

samskalicky
Copy link
Contributor

@samskalicky samskalicky commented Dec 1, 2020

Description

Support destructors for custom stateful ops

  • Adds virtual destructor for CustomStatefulOp base class
  • Added new library C API _opCallDestroyOpState to call delete on CustomStatefulOp in custom library
  • Calls delete on customStatefulOp instance in CustomStatefulOpWrapper destructor
  • Adds static create API to CustomStatefulOp to create instances of CustomStatefulOp derived classes using new. This API takes variadic args and passes them to the constructor of the templated class. For example: CustomStatefulOp::create<MyStatefulGemm>(count, attrs);
  • Adds an example destructor to the MyStatefulGemm class and calls the new create API
  • Added check to ensure instances of CustomStatefulOp were created with the create API to ensure they are allocated with new (since delete will be called on destruction) or emit a suppressible warning message.
  • Added an example suppressing the message in the MyStatefulTransposeRowSP class
  • The MyStatefulTransposeCSR class is an example where the message is emitted.

Now, when MXNet calls the destructor for the CustomStatefulOpWrapper class it will subsequently delete the instance of the CustomStatefulOp allocated with new and call the inherited class's destructor

@mxnet-bot
Copy link

Hey @samskalicky , Thanks for submitting the PR
All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands:

  • To trigger all jobs: @mxnet-bot run ci [all]
  • To trigger specific jobs: @mxnet-bot run ci [job1, job2]

CI supported jobs: [windows-gpu, sanity, windows-cpu, centos-gpu, edge, miscellaneous, unix-cpu, website, clang, centos-cpu, unix-gpu]


Note:
Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin.
All CI tests must pass before the PR can be merged.

@lanking520 lanking520 added the pr-awaiting-testing PR is reviewed and waiting CI build and test label Dec 1, 2020
@samskalicky
Copy link
Contributor Author

FYI @rondogency

@lanking520 lanking520 added pr-work-in-progress PR is still work in progress and removed pr-awaiting-testing PR is reviewed and waiting CI build and test labels Dec 1, 2020
@lanking520 lanking520 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Dec 1, 2020
Copy link
Contributor

@rondogency rondogency left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@mseth10 mseth10 left a comment

Choose a reason for hiding this comment

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

LGTM

@lanking520 lanking520 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Dec 2, 2020
@lanking520 lanking520 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Dec 3, 2020
@lanking520 lanking520 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Dec 3, 2020
@lanking520 lanking520 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress pr-awaiting-review PR is waiting for code review and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Dec 3, 2020
@samskalicky samskalicky added pr-awaiting-merge Review and CI is complete. Ready to Merge and removed pr-awaiting-review PR is waiting for code review labels Dec 3, 2020
@samskalicky samskalicky merged commit 35cab31 into apache:v1.x Dec 4, 2020
samskalicky added a commit to samskalicky/incubator-mxnet that referenced this pull request Dec 4, 2020
* initial commit

* added warning message

* added destroy function to call delete in custom library

* try removing six per apache#19604

* fixed lint

* fixed readability
samskalicky added a commit that referenced this pull request Dec 7, 2020
…9632)

* Support destructors for custom stateful ops (#19607)

* initial commit

* added warning message

* added destroy function to call delete in custom library

* try removing six per #19604

* fixed lint

* fixed readability

* fix lint

* fixed lint

* fixed override
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr-awaiting-merge Review and CI is complete. Ready to Merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants