MCPcopy Create free account
hub / github.com/pytorch/executorch / unit_factor

Function unit_factor

backends/arm/test/test_memory_allocator_log.py:21–38  ·  view source on GitHub ↗
(u: str)

Source from the content-addressed store, hash-verified

19
20
21def unit_factor(u: str) -> float:
22 if not u:
23 return 1.0
24 ul = u.strip().lower()
25 table = {
26 "b": 1,
27 "byte": 1,
28 "bytes": 1,
29 "kb": 1000,
30 "mb": 1000**2,
31 "gb": 1000**3,
32 "kib": 1024,
33 "mib": 1024**2,
34 "gib": 1024**3,
35 }
36 if ul in table:
37 return float(table[ul])
38 return 1.0
39
40
41def parse_value(text_num: str, text_unit: Optional[str]) -> float:

Callers 1

parse_valueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected