ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Util Namespace Reference

Functions

 to_filename (tensor_name)
 
 valid_attr (args, attr)
 
 pretty_float (item, ndigits=4)
 

Function Documentation

◆ pretty_float()

Util.pretty_float (   item,
  ndigits = 4 
)

Definition at line 30 of file Util.py.

30def pretty_float(item, ndigits=4):
31 if isinstance(item, dict):
32 return {k: pretty_float(v, ndigits) for k, v in item.items()}
33 if isinstance(item, list):
34 return [pretty_float(x, ndigits) for x in item]
35 if isinstance(item, float):
36 return round(item, ndigits)
37 return item

References pretty_float().

Referenced by pretty_float().

◆ to_filename()

Util.to_filename (   tensor_name)

Definition at line 19 of file Util.py.

19def to_filename(tensor_name):
20 assert isinstance(tensor_name, str)
21 return tensor_name.replace('/', '_')[-255:]
22
23
24# Check if attr is valid

◆ valid_attr()

Util.valid_attr (   args,
  attr 
)

Definition at line 25 of file Util.py.

25def valid_attr(args, attr):
26 return hasattr(args, attr) and getattr(args, attr)
27
28
29# Recursively visit items and round floats with ndigits