MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / _elementwise_flops_compute

Function _elementwise_flops_compute

python/paddle/utils/flops.py:161–172  ·  view source on GitHub ↗
(input_shapes, attrs)

Source from the content-addressed store, hash-verified

159
160
161def _elementwise_flops_compute(input_shapes, attrs):
162 input_x = input_shapes.get("X")[0]
163 input_y = input_shapes.get("Y")[0]
164 dim_x = len(input_x)
165 dim_y = len(input_y)
166 dim_output = max(dim_x, dim_y)
167 output = []
168 for i in range(dim_output):
169 in_x = input_x[dim_x - 1 - i] if i < dim_x else 1
170 in_y = input_y[dim_y - 1 - i] if i < dim_y else 1
171 output.append(max(in_x, in_y))
172 return prod(output)
173
174
175@register_flops("elementwise_add")

Callers 3

_elementwise_add_flopsFunction · 0.85
_elementwise_mul_flopsFunction · 0.85
_elementwise_div_flopsFunction · 0.85

Calls 5

rangeFunction · 0.85
prodFunction · 0.70
maxFunction · 0.50
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected