Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow functions as input to fns generated by AD #190

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion src/emmy/dual.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,9 @@
([primal tag]
(bundle-element primal 1 tag))
([primal tangent tag]
{:pre [(v/scalar? primal)]}
{:pre [(or (v/scalar? primal)
;; TODO
(isa? (v/kind primal) ::v/function))]}

Check warning on line 559 in src/emmy/dual.cljc

View check run for this annotation

Codecov / codecov/patch

src/emmy/dual.cljc#L559

Added line #L559 was not covered by tests
(if (g/zero? tangent)
primal
(->Dual tag primal tangent))))
Expand Down
5 changes: 2 additions & 3 deletions src/emmy/tape.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,9 @@
all leaves recursively replaced by [[TapeCell]] instances."
[x tag]
(cond
(v/scalar? x) (make tag x)
(or (v/scalar? x) (f/function? x)) (make tag x)
(s/structure? x) (s/mapr #(tapify % tag) x)
(f/function? x) (u/illegal "Function input not yet supported.")
:else x))
:else x))

;; ### Accessors

Expand Down
Loading