flops-counter.pytorch icon indicating copy to clipboard operation
flops-counter.pytorch copied to clipboard

how to calculate the flops for pixelshuffle operation?

Open hcleung3325 opened this issue 3 years ago • 7 comments

I have fit a model with pixelshuffle operation to this flops calculation. However, it cannot calculate the flops in pixelshuffle layer.

PixelShuffle(0.0 M, 0.000% Params, 0.0 GMac, 0.000% MACs, upscale_factor=2)

Can anyone help?

hcleung3325 avatar May 24 '21 02:05 hcleung3325

Hi sovrasov , may I know that would pixel shuffle consume floating point operation? As I cannot find any equation or information is about the flops for pixel shuffle, I wonder if this layer is a floating point operation or not? Thanks.

hcleung3325 avatar May 26 '21 05:05 hcleung3325

I've reviewed the original paper that introduced PixelShuffle and agree that it's rather a memory rearrangement operator, so the current behavior is correct.

sovrasov avatar May 26 '21 10:05 sovrasov

I've reviewed the original paper that introduced PixelShuffle and agree that it's rather a memory rearrangement operator, so the current behavior is correct.

Thanks for the clarifcation. Is that the memory rearrangement operator will not be considered as floating point operation? Is that the memory rearrangement operator still consume computational power and time?

hcleung3325 avatar May 27 '21 01:05 hcleung3325

Yep, memory rearrangement always consumes time, but it is out of scope for flops metric. I'd rather keep the straightforward flops definition to avoid misunderstanding. For such operations like PixelShuffle or even ReLU we should think about a different metric.

sovrasov avatar May 28 '21 07:05 sovrasov

Yep, memory rearrangement always consumes time, but it is out of scope for flops metric. I'd rather keep the straightforward flops definition to avoid misunderstanding. For such operations like PixelShuffle or even ReLU we should think about a different metric.

Thanks. As you said there is a paper that introduced PixelShuffle, may I have the name of it?

hcleung3325 avatar May 31 '21 10:05 hcleung3325

https://arxiv.org/abs/1609.05158

sovrasov avatar May 31 '21 10:05 sovrasov

https://arxiv.org/abs/1609.05158

Thanks.

hcleung3325 avatar Jun 01 '21 01:06 hcleung3325