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

[MXNET-618] Clojure package - move NDArray and Symbol Code generation to Automatic #11534

Merged
merged 1 commit into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contrib/clojure-package/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ src/.DS_Store
src/org/.DS_Store
test/test-ndarray.clj
test/test-symbol.clj
src/org/apache/clojure_mxnet/gen/*

7 changes: 2 additions & 5 deletions contrib/clojure-package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,9 @@ To test your installation, you should run `lein test`. This will run the test su

#### Generation of NDArray and Symbol apis

The bulk of the ndarray and symbol apis are generated via java reflection into the Scala classes. To generate, use the `dev/generator.clj` file. These generated files are checked in as source, so the only time you would need to run them is if you are updated the clojure package with an updated scala jar and want to regenerate the code.
The bulk of the ndarray and symbol apis are generated via java reflection into the Scala classes. The files are generated as a compile time step (AOT) in the `dev.generator` namespace.

To do this run the leiningen task
`lein run generate-code`

Or load in the repl and use the functions:
You may also run this manually with the repl functions:

`(generate-ndarray-file)`
and
Expand Down
2 changes: 1 addition & 1 deletion contrib/clojure-package/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
:plugins [[lein-codox "0.10.3" :exclusions [org.clojure/clojure]]
[lein-cloverage "1.0.10" :exclusions [org.clojure/clojure]]]
:codox {:namespaces [#"^org\.apache\.clojure-mxnet\.(?!gen).*"]}
:aliases {"generate-code" ["run" "-m" "dev.generator"]}
:aot [dev.generator]
:repositories [["staging" {:url "https://repository.apache.org/content/repositories/staging"
;; If a repository contains releases only setting
;; :snapshots to false will speed up dependencies.
Expand Down
13 changes: 7 additions & 6 deletions contrib/clojure-package/src/dev/generator.clj
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@


(defn generate-symbol-file []
(println "Generating symbol file")
(write-to-file all-symbol-functions symbol-gen-ns "src/org/apache/clojure_mxnet/gen/symbol.clj"))


Expand Down Expand Up @@ -311,14 +312,14 @@


(defn generate-ndarray-file []
(println "Generating ndarray file")
(write-to-file all-ndarray-functions ndarray-gen-ns "src/org/apache/clojure_mxnet/gen/ndarray.clj"))

(defn -main [& args]
(do
(println "Generating the core ndarray api from the Scala classes")
(generate-ndarray-file)
(println "Generating the core symbol api from the Scala classes")
(generate-symbol-file)))
;;; autogen the files
(do
(generate-ndarray-file)
(generate-symbol-file))


(comment

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

Loading