| 164 | PACKET_REGISTER_TYPE("bmf.lib._bmf.sdk." #T, T) |
| 165 | |
| 166 | hmp::TensorOptions parse_tensor_options(const py::kwargs &kwargs, |
| 167 | const hmp::TensorOptions &ref) { |
| 168 | using namespace hmp; |
| 169 | |
| 170 | TensorOptions opts(ref); |
| 171 | |
| 172 | if (kwargs.contains("pinned_memory")) { |
| 173 | opts = opts.pinned_memory(py::cast<bool>(kwargs["pinned_memory"])); |
| 174 | } |
| 175 | |
| 176 | if (kwargs.contains("device")) { |
| 177 | auto device = kwargs["device"]; |
| 178 | if (PyUnicode_Check(device.ptr())) |
| 179 | opts = opts.device(py::cast<std::string>(kwargs["device"])); |
| 180 | else if (py::isinstance<Device>(kwargs["device"])) |
| 181 | opts = opts.device(py::cast<Device>(kwargs["device"])); |
| 182 | else |
| 183 | opts = opts.device(py::cast<DeviceType>(kwargs["device"])); |
| 184 | } |
| 185 | |
| 186 | if (kwargs.contains("dtype")) { |
| 187 | opts = opts.dtype(py::cast<ScalarType>(kwargs["dtype"])); |
| 188 | } |
| 189 | |
| 190 | return opts; |
| 191 | } |
| 192 | |
| 193 | struct PyPacketQueue { |
| 194 | PyPacketQueue(const std::shared_ptr<std::queue<bmf_sdk::Packet>> &queue) |
no test coverage detected