| 1298 | } |
| 1299 | |
| 1300 | static PyObject *SmithWaterman_call(SmithWaterman *self, PyObject *args, PyObject *kwargs) { |
| 1301 | PyObject *a_obj = NULL, *b_obj = NULL, *device_obj = NULL, *out_obj = NULL; |
| 1302 | |
| 1303 | static char *kwlist[] = {"a", "b", "device", "out", NULL}; |
| 1304 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|OO", kwlist, &a_obj, &b_obj, &device_obj, &out_obj)) return NULL; |
| 1305 | |
| 1306 | // Get device handle |
| 1307 | szs_device_scope_t device_handle = default_device_scope; |
| 1308 | if (device_obj && device_obj != Py_None) { |
| 1309 | if (!PyObject_IsInstance(device_obj, (PyObject *)&DeviceScopeType)) { |
| 1310 | PyErr_SetString(PyExc_TypeError, "device must be a DeviceScope instance"); |
| 1311 | return NULL; |
| 1312 | } |
| 1313 | device_handle = ((DeviceScope *)device_obj)->handle; |
| 1314 | } |
| 1315 | |
| 1316 | sz_size_t kernel_input_size = 0; |
| 1317 | void const *kernel_a_texts_punned = NULL; |
| 1318 | void const *kernel_b_texts_punned = NULL; |
| 1319 | sz_status_t (*kernel_punned)(szs_smith_waterman_scores_t, szs_device_scope_t, void const *, void const *, |
| 1320 | sz_ssize_t *, sz_size_t, char const **) = NULL; |
| 1321 | |
| 1322 | // Swap allocators only when using CUDA with a GPU device (inputs must be unified) |
| 1323 | if (requires_unified_memory(self->capabilities)) |
| 1324 | if (!try_swap_to_unified_allocator(a_obj) || !try_swap_to_unified_allocator(b_obj)) return NULL; |
| 1325 | |
| 1326 | // Handle 32-bit tape inputs |
| 1327 | sz_sequence_u32tape_t a_u32tape, b_u32tape; |
| 1328 | sz_bool_t a_is_u32tape = sz_py_export_strings_as_u32tape( // |
| 1329 | a_obj, &a_u32tape.data, &a_u32tape.offsets, &a_u32tape.count); |
| 1330 | sz_bool_t b_is_u32tape = sz_py_export_strings_as_u32tape( // |
| 1331 | b_obj, &b_u32tape.data, &b_u32tape.offsets, &b_u32tape.count); |
| 1332 | if (a_is_u32tape && b_is_u32tape) { |
| 1333 | if (a_u32tape.count != b_u32tape.count) { |
| 1334 | PyErr_SetString(PyExc_ValueError, "Input sequences must have the same length"); |
| 1335 | return NULL; |
| 1336 | } |
| 1337 | kernel_input_size = a_u32tape.count; |
| 1338 | kernel_punned = szs_smith_waterman_scores_u32tape; |
| 1339 | kernel_a_texts_punned = &a_u32tape; |
| 1340 | kernel_b_texts_punned = &b_u32tape; |
| 1341 | } |
| 1342 | |
| 1343 | // Handle 64-bit tape inputs |
| 1344 | sz_sequence_u64tape_t a_u64tape, b_u64tape; |
| 1345 | sz_bool_t a_is_u64tape = !a_is_u32tape && sz_py_export_strings_as_u64tape( // |
| 1346 | a_obj, &a_u64tape.data, &a_u64tape.offsets, &a_u64tape.count); |
| 1347 | sz_bool_t b_is_u64tape = !b_is_u32tape && sz_py_export_strings_as_u64tape( // |
| 1348 | b_obj, &b_u64tape.data, &b_u64tape.offsets, &b_u64tape.count); |
| 1349 | if (a_is_u64tape && b_is_u64tape) { |
| 1350 | if (a_u64tape.count != b_u64tape.count) { |
| 1351 | PyErr_SetString(PyExc_ValueError, "Input sequences must have the same length"); |
| 1352 | return NULL; |
| 1353 | } |
| 1354 | kernel_input_size = a_u64tape.count; |
| 1355 | kernel_punned = szs_smith_waterman_scores_u64tape; |
| 1356 | kernel_a_texts_punned = &a_u64tape; |
| 1357 | kernel_b_texts_punned = &b_u64tape; |
nothing calls this directly
no test coverage detected
searching dependent graphs…