Skip to content

Target argument for scale, map etc#190

Open
digikar99 wants to merge 2 commits intoquil-lang:masterfrom
digikar99:target-for-scale-map
Open

Target argument for scale, map etc#190
digikar99 wants to merge 2 commits intoquil-lang:masterfrom
digikar99:target-for-scale-map

Conversation

@digikar99
Copy link
Copy Markdown

Intended to complete #175

Let me know if this works.

And I can add for more functions, but is there any exhaustive list on mind?

Comment on lines +111 to +112
(:method ((function function) (tensor abstract-tensor &optional (target nil targetp)))
(map! function (if targetp target (deep-copy-tensor tensor)))))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't apply function to tensor when targetp.

This change isn't actually necessary for map because we have map-to above.

Comment on lines 140 to +145
(define-backend-implementation scale :lisp
(lambda (tensor factor)
(scale! (deep-copy-tensor tensor) factor)))
(lambda (tensor factor &optional (target nil targetp))
(scale! (if targetp
target
(deep-copy-tensor tensor))
factor)))
Copy link
Copy Markdown
Contributor

@YarinHeffes YarinHeffes Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the issue above, this change doesn't actually scale the elements of tensor into target but rather scales the elements of target itself.

Edit: My recommendation is to add a function scale-to modeled after map-to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants