Chouffe commented on a change in pull request #14750: [clojure][generator][WIP]
add random namespace generation
URL: https://github.com/apache/incubator-mxnet/pull/14750#discussion_r278188298
##########
File path: contrib/clojure-package/src/dev/generator.clj
##########
@@ -470,6 +476,53 @@
(println "Generating symbol-api file")
(write-to-file all-symbol-api-functions symbol-api-gen-ns
"src/org/apache/clojure_mxnet/gen/symbol_api.clj"))
+;;;;;;; SymbolRandomAPI
+
+(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)
+ params (mapv (fn [{:keys [name type optional?] :as opts}]
+ (assoc opts
+ :sym (symbol name)
+ :optional? (or optional?
+ (= "NDArray-or-Symbol" type))))
+ (conj args
+ {:name "name"
+ :type "String"
+ :optional? true
+ :description "Name of the symbol"}
+ {:name "attr"
+ :type "Map[String, String]"
+ :optional? true
+ :description "Attributes of the symbol"}))
+ doc (gen-symbol-api-doc fn-description params)
+ default-call (gen-symbol-api-default-arity op-name params)]
+ `(~'defn ~(symbol fn-name)
+ ~doc
+ ~@default-call)))
+
+(def all-symbol-random-api-functions
+ (->> op-names
+ (filter #(clojure.string/includes? % "random_"))
+ (mapv gen-symbol-random-api-function)))
+
+(def symbol-random-api-gen-ns "(ns
+ ^{:doc \"Experimental\"}
+ org.apache.clojure-mxnet.symbol-random-api
+ (:refer-clojure :exclude [* - + > >= < <= / cast concat identity flatten
load max
+ min repeat reverse set sort take to-array empty sin
+ 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)))")
Review comment:
I could not get it to work. Do you have any pointers on how this should be
done?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services