Constructs a PyBfloat16 object from a bfloat16.
| 118 | |
| 119 | // Constructs a PyBfloat16 object from a bfloat16. |
| 120 | Safe_PyObjectPtr PyBfloat16_FromBfloat16(bfloat16 x) { |
| 121 | Safe_PyObjectPtr ref = |
| 122 | make_safe(PyBfloat16_Type.tp_alloc(&PyBfloat16_Type, 0)); |
| 123 | PyBfloat16* p = reinterpret_cast<PyBfloat16*>(ref.get()); |
| 124 | if (p) { |
| 125 | p->value = x; |
| 126 | } |
| 127 | return ref; |
| 128 | } |
| 129 | |
| 130 | // Converts a Python object to a bfloat16 value. Returns true on success, |
| 131 | // returns false and reports a Python error on failure. |
no test coverage detected