Is there an efficient way to do tensor-scalar addition? #811
Answered
by
slaren
balisujohn
asked this question in
Q&A
-
Right now the most efficient way I know how to do it is create tensor with the same size as the target tensor, then manually set its all its values to the scalar value before running the computational graph, then running the computational graph and adding the the tensor holding the scalar to the target tensor. This seems brutally inefficient computationally; is there a better way to add a scalar to each value in a tensor? |
Beta Was this translation helpful? Give feedback.
Answered by
slaren
May 3, 2024
Replies: 1 comment
-
The add operation support broadcasting, so you only really need a 1 element tensor. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
balisujohn
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The add operation support broadcasting, so you only really need a 1 element tensor.