in models/src/ptflops/flops_counter.py [0:0]
def flops_to_string(flops, units="GMac", precision=2):
if units is None:
if flops // 10 ** 9 > 0:
return str(round(flops / 10.0 ** 9, precision)) + " GMac"
elif flops // 10 ** 6 > 0:
return str(round(flops / 10.0 ** 6, precision)) + " MMac"
elif flops // 10 ** 3 > 0:
return str(round(flops / 10.0 ** 3, precision)) + " KMac"
else:
return str(flops) + " Mac"
else:
if units == "GMac":
return str(round(flops / 10.0 ** 9, precision)) + " " + units
elif units == "MMac":
return str(round(flops / 10.0 ** 6, precision)) + " " + units
elif units == "KMac":
return str(round(flops / 10.0 ** 3, precision)) + " " + units
else:
return str(flops) + " Mac"