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

[clojure-package] add ->nd-vec function in ndarray.clj #14308

Merged
merged 2 commits into from
Mar 10, 2019
Merged

[clojure-package] add ->nd-vec function in ndarray.clj #14308

merged 2 commits into from
Mar 10, 2019

Conversation

Chouffe
Copy link
Contributor

@Chouffe Chouffe commented Mar 3, 2019

Description

Proposal for adding a ->nd-vec function in ndarray.clj

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:https://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

@Chouffe Chouffe requested a review from gigasquid as a code owner March 3, 2019 20:02
@anirudhacharya
Copy link
Member

@mxnet-label-bot add [pr-work-in-progress, Clojure]

@Chouffe
Copy link
Contributor Author

Chouffe commented Mar 5, 2019

I would love some feedback on this @kedarbellare @gigasquid :-)

@gigasquid
Copy link
Member

taking a look 👀

Copy link
Member

@gigasquid gigasquid left a comment

Choose a reason for hiding this comment

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

@Chouffe I think it looks really good 👍

Just a few minor comments, but I think it is a great direction and with some tests would be ready to merge.

Thanks for making this come to life!

(if-not (seq ss)
(vec v)
(->> v
(partition (/ (count v) s1))
Copy link
Member

Choose a reason for hiding this comment

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

You will need to use clojure.core// instead of just / because the ndarray has a definition for the operator in this namespace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch!

[org.apache.clojure-mxnet.context :as mx-context]
[org.apache.clojure-mxnet.shape :as mx-shape]
[org.apache.clojure-mxnet.util :as util]
[clojure.reflect :as r]
Copy link
Member

Choose a reason for hiding this comment

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

Do you mind cleaning up `[clojure.reflect ] while you are in here? It should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

Ex:
(->nd-vec (array [1] [1 1 1])) ;[[[1.0]]]
(->nd-vec (ndarray/array [1 2 3] [3 1 1])) ;[[[1.0]] [[2.0]] [[3.0]]]"
[ndarray]
Copy link
Member

Choose a reason for hiding this comment

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

I like the function spec, do you think it would also be nice to be able to do a util/validate in here to check that it is a NDArray? when called without instrumentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes lets do that!

Copy link
Contributor

@kedarbellare kedarbellare left a comment

Choose a reason for hiding this comment

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

mostly lgtm. adding tests would be great!

(s/def ::ndarray #(instance? NDArray %))
(s/def ::vector vector?)
(s/def ::shape-vec-match-vec
(fn [[v vec-shape]] (= (count v) (reduce * 1 vec-shape))))
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

Copy link
Contributor

@kedarbellare kedarbellare left a comment

Choose a reason for hiding this comment

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

lgtm!

@Chouffe
Copy link
Contributor Author

Chouffe commented Mar 10, 2019

Unit tests added and all checks have passed!

@gigasquid gigasquid changed the title [clojure-package][wip] add ->nd-vec function in ndarray.clj [clojure-package] add ->nd-vec function in ndarray.clj Mar 10, 2019
@gigasquid
Copy link
Member

Thanks for your contribution @Chouffe 😸

@gigasquid gigasquid merged commit 8be97d7 into apache:master Mar 10, 2019
vdantu pushed a commit to vdantu/incubator-mxnet that referenced this pull request Mar 31, 2019
…he#14308)

* [clojure-package][wip] add `->nd-vec` function in `ndarray.clj`

* WIP
* Unit tests need to be added

* [clojure-package][ndarray] add unit tests for `->nd-vec` util fn
nswamy pushed a commit that referenced this pull request Apr 5, 2019
* [clojure-package][wip] add `->nd-vec` function in `ndarray.clj`

* WIP
* Unit tests need to be added

* [clojure-package][ndarray] add unit tests for `->nd-vec` util fn
haohuanw pushed a commit to haohuanw/incubator-mxnet that referenced this pull request Jun 23, 2019
…he#14308)

* [clojure-package][wip] add `->nd-vec` function in `ndarray.clj`

* WIP
* Unit tests need to be added

* [clojure-package][ndarray] add unit tests for `->nd-vec` util fn
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Clojure pr-work-in-progress PR is still work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants