Constructs a PyBfloat16 object from a bfloat16.
| 94 | |
| 95 | // Constructs a PyBfloat16 object from a bfloat16. |
| 96 | Safe_PyObjectPtr PyBfloat16_FromBfloat16(bfloat16 x) { |
| 97 | Safe_PyObjectPtr ref = |
| 98 | make_safe(PyBfloat16_Type.tp_alloc(&PyBfloat16_Type, 0)); |
| 99 | PyBfloat16* p = reinterpret_cast<PyBfloat16*>(ref.get()); |
| 100 | if (p) { |
| 101 | p->value = x; |
| 102 | } |
| 103 | return ref; |
| 104 | } |
| 105 | |
| 106 | // Converts a Python object to a bfloat16 value. Returns true on success, |
| 107 | // returns false and reports a Python error on failure. |
no test coverage detected