KEMBAR78
Inplace subtraction only via a:add(-1, b)? · Issue #362 · torch/torch7 · GitHub
Skip to content

Inplace subtraction only via a:add(-1, b)? #362

@andreaskoepf

Description

@andreaskoepf

A remark to one of the most basic tensor operations:
If you want to compute the difference between two tensors inplace and you list the tensor members everything looks fine since there are add(), mul(), div() (all offering an optional inplace-semantic) and a method called sub() .. unfortunately sub() stands for extracting sub-tensors and not for computing the difference. The only method I found for computing the difference inplace seems to be [res] torch.add([res,] tensor1, value, tensor2) when used with -1 as factor.

Have I missed something?
Could this be added to the math documentation?
Are there any speed penalties for the -1 multiplication?
Have you considered adding a dedicated subtraction function, e.g. called subt() or subtract()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions