Apply conversion to val. Recursively apply conversion if `val` #is a nested tuple/list structure.
(val, conversion)
| 115 | |
| 116 | |
| 117 | def conversion_helper(val, conversion): |
| 118 | """Apply conversion to val. Recursively apply conversion if `val` |
| 119 | #is a nested tuple/list structure.""" |
| 120 | if not isinstance(val, (tuple, list)): |
| 121 | return conversion(val) |
| 122 | rtn = [conversion_helper(v, conversion) for v in val] |
| 123 | if isinstance(val, tuple): |
| 124 | rtn = tuple(rtn) |
| 125 | return rtn |
| 126 | |
| 127 | |
| 128 | def fp32_to_float16(val, float16_convertor): |
no outgoing calls
no test coverage detected