These methods are needed in addition to the above template methods because pybind does not allow us to expose template methods to Python with gcc on Linux.
| 54 | // because pybind does not allow us to expose template methods to |
| 55 | // Python with gcc on Linux. |
| 56 | u_int64_t MilStoragePythonWriter::write_int4_data(const py::array_t<int8_t>& data) { |
| 57 | // The `data` is stored in int8 because numpy doesn't support int4. |
| 58 | // First pack those int4 data into uint8 Span, and then cast to int4 Span and write it. |
| 59 | auto int8SpanData = MILBlob::Util::Span<const int8_t>(data.data(), data.size()); |
| 60 | std::vector<uint8_t> packedValues = MILBlob::PackInt8Span<MILBlob::Int4>(int8SpanData); |
| 61 | auto packedValuesSpan = MILBlob::Util::Span<const uint8_t>(packedValues.data(), packedValues.size()); |
| 62 | auto int4Span = MILBlob::Util::CastToBitSpan<const MILBlob::Int4>(packedValuesSpan, data.size()); |
| 63 | return m_writer->WriteData<MILBlob::Int4>(int4Span); |
| 64 | } |
| 65 | |
| 66 | u_int64_t MilStoragePythonWriter::write_uint1_data(const py::array_t<uint8_t>& data) { |
| 67 | return writeUnsignedSubByteData<MILBlob::UInt1>(*m_writer, data); |