Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Let's take the simple ndarray activation function as an example to see what the ideal state would look like:

(s/def ::ndarray ...#(instance? NDArray %))
(s/def ::act-type #{"relu" "sigmoid" ...})
(s/fdef ::activation ...)

(defn activation

...

   ([data weight bias kernel num-filter
{:keys [stride
dilate pad num-group workspace
no-bias cudnn-tune cudnn-off layout out]
:as opts}]

...

We should also encourage the usage of Clojure data structures as function arguments:

ScalaClojure
Int | Float | Double | Boolean | Stringint | float | double | bool | string
Array[Int] | Array[...] | Array[NDArray]vec-of-ints | vec-of-... | vec-of-ndarrays
scala.collection.immutable.Mapmap (i.e. {...})
org.apache.mxnet.Shapevec-of-ints (e.g. [2 3])

function(req_arg: ..., opt_shape: Option[Shape] = Some(...), ...) {

    ...

}

(defn function

  [req-arg

   {:keys [opt-shape]

    :or {opt-shape [3 5]}

    :as opts}] ...)
 

Potential Approach(es)

We can potentially use the Scala package's GeneratorBase to create the functions described above. The current challenge is that the generator cannot be called directly from within Clojure and hence we have to rely on reflection instead.

...