MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / clever_format

Function clever_format

PATH/helper/flops_helper.py:12–32  ·  view source on GitHub ↗
(nums, format="%.2f")

Source from the content-addressed store, hash-verified

10
11
12def clever_format(nums, format="%.2f"):
13 if not isinstance(nums, Iterable):
14 nums = [nums]
15 clever_nums = []
16
17 for num in nums:
18 num = int(num)
19 if num > 1e12:
20 clever_nums.append(format % (num / 1e12) + "T")
21 elif num > 1e9:
22 clever_nums.append(format % (num / 1e9) + "G")
23 elif num > 1e6:
24 clever_nums.append(format % (num / 1e6) + "M")
25 elif num > 1e3:
26 clever_nums.append(format % (num / 1e3) + "K")
27 else:
28 clever_nums.append(format % num + "B")
29
30 clever_nums = clever_nums[0] if len(clever_nums) == 1 else (*clever_nums,)
31
32 return clever_nums
33
34
35def flops_cal(model, input_shape):

Callers 1

flops_calFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected