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

MXNET-873 - Bring Clojure Package Inline with New DataDesc and Layout in Scala Package #12387

Merged
merged 8 commits into from
Sep 13, 2018

Conversation

gigasquid
Copy link
Member

Description

The Scala package has updated the DataDesc to include Layout. The Clojure package has been updated to move inline with it.

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

  • A layout namespace has been created and used in DataDesc
  • The Clojure package no longer infers the layout from the shape. It handles it the same way as the Scala package by having it be undefined
  • The original module.fit interop code has been restored. The work arounds required by the old DataDesc has been resolved with this PR [MXNET-689] add DataDesc type for the Scala Package #11844
  • Most of the examples have moved to use provide-data-desc instead of provide-data
  • Formatting fixes
  • Tweak to Char RNN example to run for less epochs before showing the pre-loaded result

@gigasquid
Copy link
Member Author

@lanking520 please give a look when you get a chance

@gigasquid gigasquid changed the title MXNET-873 - Bring Clojure Package inline with new DataDesc and Layout in Scala Package MXNET-873 - Bring Clojure Package Inline with New DataDesc and Layout in Scala Package Aug 28, 2018
Copy link
Member

@lanking520 lanking520 left a comment

Choose a reason for hiding this comment

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

Thanks for your effort pushing the same changes on Clojure! Overall looks good

@@ -92,7 +92,7 @@

(comment

(predict "https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/doc/tutorials/python/predict_image/cat.jpg")
(predict "https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/doc/tutorials/python/predict_image/cat.jpg" true)
Copy link
Member

Choose a reason for hiding this comment

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

What does this true mean in here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

nit: not a big deal since it's a helper fn in an example, but it'd make sense to use an options map or kw arg ({:display true} or :display true). [outside this PR though, also]

Copy link
Member Author

Choose a reason for hiding this comment

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

yes agree

@@ -144,7 +144,7 @@
which must be known from the rest of the net."
([start {:keys [step repeat dtype]
:or {step (float 1) repeat (int 1) dtype base/MX_REAL_TYPE}
:as opts}]
:as opts}]
Copy link
Member

Choose a reason for hiding this comment

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

space issue...

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case the cljfmt tool is fixing my earlier mistake :)

@gigasquid
Copy link
Member Author

Thanks for the feedback @lanking520 😸

@lanking520
Copy link
Member

@gigasquid Sorry about not being so helpful there... I will try to learn Clojure grammer and review it again... Generally, the Scala DataDesc want user to pass in as DataDesc type instead of ListMap. Then most of the iterators needs to change a little bit based on this change.

@gigasquid
Copy link
Member Author

Thanks @lanking520 I did change the NDarrayIter to reflect this change. You can probably see it easiest in the test case https://github.com/apache/incubator-mxnet/pull/12387/files#diff-93817a3c2dc0abcdbb709a400bddc997R194

Please feel free to ping me with any questions.

last-batch-handle
data-name
label-name))
(let [specify-data-desc? (map? data)]

Choose a reason for hiding this comment

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

nit: is this just in the let for a self-documenting name/rationale?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it can be dropped - thanks

Copy link

@benkamphaus benkamphaus left a comment

Choose a reason for hiding this comment

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

just a nit, otherwise LGTM

@gigasquid
Copy link
Member Author

Thanks for the feedback @benkamphaus.

@nswamy/ @szha - I think this is ready for a final review

@lanking520
Copy link
Member

@nswamy @yzhliu Please take a look since it's been for a while

@szha szha requested a review from yzhliu September 2, 2018 19:08
@gigasquid gigasquid added the pr-awaiting-review PR is waiting for code review label Sep 3, 2018
Copy link
Member

@yzhliu yzhliu left a comment

Choose a reason for hiding this comment

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

good to me for the rest.

last-batch-handle
data-name
label-name))
(if (map? data)
Copy link
Member

Choose a reason for hiding this comment

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

does it mean if data is map? what if it is not? I don't know clojure well, just want to make sure it is intended.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes - it checks to see if the data is a map, if so, it is in the form of having a DataDesc associated with it and will be dispatched to the correct Java function signature and with scala interop. If it is not a map, it will dispatch to the original Java function signature without DataDesc.

The argument checking for the correct data structures can be improved by using core.spec in Clojure. It adds gradual type checking. It is in use in the module api, but it hasn't been added in yet in this namespace. I added a line item in the TODO page for the Clojure package to capture it for later improvement work.

@gigasquid
Copy link
Member Author

Thanks @yzhliu for the feedback 😸

Unless anyone has any objections, I will go ahead a merge shortly.

@gigasquid gigasquid removed the pr-awaiting-review PR is waiting for code review label Sep 13, 2018
@gigasquid gigasquid merged commit b8153f6 into apache:master Sep 13, 2018
@gigasquid gigasquid deleted the update-data-desc-clojure branch September 13, 2018 00:06
anirudh2290 pushed a commit to anirudh2290/mxnet that referenced this pull request Sep 19, 2018
… in Scala Package (apache#12387)

* Bring clojure package inline with new DataDesc and Layout in Scala package

* formatting cljfmt

* revert the implementation of module fit back now that DataDesc issue if fixed
- update Module example to use provide-data-desc and provide-label-desc

* update to provide-data-desc and provide-label-desc

* decrease epochs to speed example

* Add tests and docstrings

* remove let
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants