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

Question about add operation count in different case #134

Open
LOSKIw opened this issue Mar 7, 2024 · 0 comments
Open

Question about add operation count in different case #134

LOSKIw opened this issue Mar 7, 2024 · 0 comments

Comments

@LOSKIw
Copy link

LOSKIw commented Mar 7, 2024

After going through the source code, I found that in different func the addition operation is count in different style

in torch.add all addition seems to be counted

while in some matrices multiplication, part of the addition is not

one example is in torch,addmm,

input + mat1 @ mat2

def _addmm_tensor_flops_hook(input, mat1, mat2, *, beta=1, alpha=1, out=None):
    flops = np.prod(mat1.shape, dtype=np.int64) * mat2.shape[-1]
    if beta != 0:
        flops += np.prod(input.shape, dtype=np.int64)
    return flops

the addition of input + new matrix is included, while the addition in mat1 @ mat2 seems not been considered

assume mat1 and mat2 have shape m*n and n*l, the total operation output for addmm will be m*n*l+m*l, but I think it might be m*n*l+(n-1)*m*l+m*l=2*m*n*l

I understand that addition might affect little to the total process, but maybe a constant regulation for computing will be more reasonable? Or is there any error in my expression, like in real case we could have some extra condition?

Thank you very much

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

No branches or pull requests

1 participant