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

[MXNET-531] Custom Operator Example for Scala #11401

Merged
merged 8 commits into from
Jul 18, 2018
Merged

Conversation

lanking520
Copy link
Member

@lanking520 lanking520 commented Jun 26, 2018

Description

This is the example written in new API in Scala. It include the following two tests:

customOp : Runs only on CPU

customOpRtc: Runs only on GPU

I also add some modification on Macros to disable Custom operator from generation. Instead, I create a Custom Operator in SymbolAPI. Add TODO in NDArray's one.

@nswamy @yzhliu @andrewfayres

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


import org.apache.mxnet.{DataIter, IO, Shape}

/**
Copy link
Member

Choose a reason for hiding this comment

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

no author tags


@AddSymbolAPIs(false)
/**
* typesafe Symbol API: Symbol.api._
* Main code will be generated during compile time through Macros
*/
object SymbolAPI extends SymbolAPIBase {
def Custom (op_type : String, kwargs : mutable.Map[String, Any],
name : String = null, attr : Map[String, String] = null) : Symbol = {
Copy link
Member

Choose a reason for hiding this comment

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

should your Custom Op also take optional Seq() for positional arguments?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, kwargs should be able to maintain all customer needs to create a custom Op.

@lanking520 lanking520 force-pushed the customop branch 2 times, most recently from c77b804 to d3f8898 Compare July 3, 2018 22:31
@yzhliu
Copy link
Member

yzhliu commented Jul 11, 2018

Can we merge?

@nswamy nswamy merged commit 072dd5a into apache:master Jul 18, 2018
@lanking520 lanking520 deleted the customop branch July 18, 2018 20:26
KellenSunderland pushed a commit to KellenSunderland/incubator-mxnet that referenced this pull request Jul 21, 2018
Update Custom Operator Example to use new Symbol.api
XinYao1994 pushed a commit to XinYao1994/incubator-mxnet that referenced this pull request Aug 29, 2018
Update Custom Operator Example to use new Symbol.api
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