tilus.Script.add¶
- Script.add(lhs, rhs, out=None)[source]¶
Add two register tensors element-wise.
This instruction computes the element-wise addition of two register tensors lhs and rhs. The result is a new register tensor with the same dtype.
This instruction supports broadcasting, so if the shapes of lhs and rhs are not the same, they will be broadcasted to a common shape before performing the addition. The broadcasting rules are similar to those in NumPy and PyTorch, where dimensions of size 1 can be expanded to match the other tensor’s shape.
- Parameters:
lhs (RegisterTensor) – The left-hand side register tensor to add.
rhs (RegisterTensor) – The right-hand side register tensor to add.
out (RegisterTensor, optional) – The register tensor to store the result. If not provided, a new register tensor will be allocated.
- Returns:
ret – The register tensor containing the element-wise sum of lhs and rhs. The shape of the output tensor will be determined by the broadcasting rules applied to lhs and rhs.
- Return type: