hikettei / cl-waffe2

[Experimental] Graph and Tensor Abstraction for Deep Learning all in Common Lisp
https://hikettei.github.io/cl-waffe2/
MIT License
133 stars 5 forks source link

[Enhancement] Added: define-composite-function #15

Closed hikettei closed 1 year ago

hikettei commented 1 year ago

Introducing new macro define-composite-function:

(defmodel (ComposedFunction (self)
       :where (A[~] B[~] -> [~])
       :on-call-> ((self x y)
               (declare (ignore self))
               (!mul (!sin (!add x y)) (!cos (!add x y)))))

(define-composite-function (ComposedFunction) !composed)

(!composed (randn `(10 10)) (randn `(10 10))) ;; first call includes compiling time...
(!composed (randn `(10 10)) (randn `(10 10))) ;; second call is inlined and works fast.