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

[clojure][generator][WIP] add random namespace generation #14750

Closed

Conversation

Chouffe
Copy link
Contributor

@Chouffe Chouffe commented Apr 20, 2019

PR moved here: #14800

Description

Split random functions in their own generated namespace.

  • ndarray_random_api
  • symbol_random_api

It renames the following functions to be as close as possible to the scala names:

  • -random-randint into randint
  • sample-randint into randint-likefor instance and put them under ndarray-random-api namespace.

TODO

  • Unify random and sample functions (mu vs loc and sigma)

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

  • Feature1, tests, (and when applicable, API doc)
  • Feature2, tests, (and when applicable, API doc)

Comments

  • If this change is a backward incompatible change, why must this change be made.
  • Interesting edge cases to note here

* `ndarray_random_api`
* `symbol_random_api`
@Chouffe Chouffe requested a review from gigasquid as a code owner April 20, 2019 07:17
@Chouffe
Copy link
Contributor Author

Chouffe commented Apr 20, 2019

cc @kedarbellare :-)

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.

looks like a great start! there are a few things to change:

  1. DRY the code a bit (to share as much as possible between symbol/ndarray api and random api)
  2. call the scala SymbolRandomAPI and NDArrayRandomAPI
  3. unify the random_ and sample_ methods (and remove them from the ndarray/symbol api namespaces)
  4. add unit tests

contrib/clojure-package/src/dev/generator.clj Outdated Show resolved Hide resolved

(defn gen-symbol-random-api-function [op-name]
(let [{:keys [fn-name fn-description args]} (gen-op-info op-name)
fn-name (remove-prefix "-random-" fn-name)
Copy link
Contributor

Choose a reason for hiding this comment

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

get apply shuffle ref])
(:require [org.apache.clojure-mxnet.util :as util]
[org.apache.clojure-mxnet.shape :as mx-shape])
(:import (org.apache.mxnet SymbolAPI)))")
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 Author

Choose a reason for hiding this comment

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

I could not get it to work. Do you have any pointers on how this should be done?

@Chouffe
Copy link
Contributor Author

Chouffe commented Apr 24, 2019

@kedarbellare

  1. Done
  2. I could not get this to work when calling directly the NDArrayRandomAPI and the SymbolRandomAPI
  3. This is not done yet. I am not entirely sure how to do that. Can it be done in a subsequent PR?
  4. Done

@Chouffe
Copy link
Contributor Author

Chouffe commented Apr 24, 2019

cc @gigasquid for feedback on the generator namespace. I am not yet comfortable with the code there ^^

@Chouffe
Copy link
Contributor Author

Chouffe commented Apr 25, 2019

I reopened a PR here: #14800

@roywei
Copy link
Member

roywei commented Apr 29, 2019

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

@marcoabreu marcoabreu added Clojure pr-work-in-progress PR is still work in progress labels Apr 29, 2019
@Chouffe Chouffe closed this May 2, 2019
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.

4 participants