在python上编写cuda函数

时间:2019-05-17 14:36:12

标签: python python-3.x cuda numba

我正在制作Needleman-Wunsch算法。该代码在2个字符之间进行比较,并根据比较结果乘以一个数字。我想在python上编写cuda函数,并在代码中使用了一些示例。但是我遇到了一些错误。

enter image description here

import numpy as np
from numba import vectorize

class Sequence():   
    @vectorize(["int(object, array, string, string)"], target='cuda')
    def calculate(self,array, Sequence_1, Sequence_2):
        # array = np.arange(boyut ** 2).reshape(boyut, boyut)
        Gap = -2
        Mismatch = -1
        Match = 1
        boyut = 201

        for i in range(1, boyut):
            for j in range(1, boyut):
                # print(max(array[i, j - 1], array[i - 1, j], kiyasla(i, j)))
                tempi=i-1
                tempj=j-1
                array[i, j] = max(array[i, tempj] + Gap, array[tempi, j] + Gap, compare(Sequence_1[tempi], Sequence_1[tempj]) + array[tempi, tempj])

        return array[-1][-1]


def compare(deg1, deg2):
    if deg1 == deg2:
        return 1
    else:
        return -1

0 个答案:

没有答案