Skip to content

Commit

Permalink
Move the auto-generation for the ndarray and symbol files to compile …
Browse files Browse the repository at this point in the history
…time (AOT) (apache#11534)

- Do not check in generated files anymore
- Add to gitignore
  • Loading branch information
gigasquid authored and yzhliu committed Jul 3, 2018
1 parent 34fafb4 commit e94146f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13,264 deletions.
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

0 comments on commit e94146f

Please sign in to comment.