Exemplo n.º 1
0
 def makeMap(self):
     self.map = pti.new("ptiIndex **")
     self.map = pti.cast("ptiIndex **",
                         PTI.malloc(2 * pti.sizeof(self.map)))
     self.map[0] = pti.cast(
         "ptiIndex *",
         PTI.malloc(self.address.nrows * pti.sizeof(pti.new("ptiIndex *"))))
     for i in range(self.address.nrows):
         self.map[0][i] = i
     self.map[1] = pti.cast(
         "ptiIndex *",
         PTI.malloc(self.address.ncols * pti.sizeof(pti.new("ptiIndex *"))))
     for i in range(self.address.ncols):
         self.map[1][i] = i
Exemplo n.º 2
0
 def __init__(self, ncols, nrows):
     self.nthreads = (int)(os.popen('grep -c cores /proc/cpuinfo').read())
     print(self.nthreads)
     self.address = pti.cast(
         "ptiMatrix *",
         PTI.malloc(self.nthreads * pti.sizeof(pti.new("ptiMatrix *"))))
     PTI.ptiMakeMatrixBuff(self.address, ncols, nrows)
Exemplo n.º 3
0
 def __init__(self, size):
     self.nthreads = (int)(os.popen('grep -c cores /proc/cpuinfo').read())
     print(self.nthreads)
     self.address = pti.cast(
         "ptiValueVector *",
         PTI.malloc(self.nthreads *
                    pti.sizeof(pti.new("ptiValueVector *"))))
     PTI.ptiMakeVectorBuff(self.address, size)
Exemplo n.º 4
0
 def convert(self, type="", blockbits=7, superblockbits=7):
     if (type == "hicoo"):
         result = HiCOOMatrix()
         nnz = pti.new("uint64_t *", self.nnz())
         PTI.ptiSparseMatrixToHiCOO(result.address, nnz, self.address,
                                    blockbits, superblockbits)
     elif (type == "csr"):
         result = CSRMatrix()
         PTI.ptiSparseMatrixToCSR(result.address, self.address)
     elif (type == "dense"):
         result = DenseMatrix(self.address.nrows, self.address.ncols)
         for i in range(self.address.nnz):
             m = self.address.rowind.data[i]
             n = self.address.colind.data[i]
             data = self.address.values.data[i]
             result.setValue(m, n, data)
     else:
         print("[ERROR] Wrong sparse matrix type.")
     return result
Exemplo n.º 5
0
 def __init__(self):
     self.address = pti.new("ptiSparseTensor *")
     self.dimentions = 0
     self.nthreads = (int)(os.popen('grep -c cores /proc/cpuinfo').read())
Exemplo n.º 6
0
 def __init__(self):
     self.address = pti.new("ptiSemiSparseTensorGeneral *")
Exemplo n.º 7
0
 def __init__(self):
     self.address = pti.new("ptiSparseTensorHiCOO *")
Exemplo n.º 8
0
 def __init__(self, length):
     self.address = pti.new("ptiValueVector *")
     PTI.ptiNewValueVector(self.address, length, length)
Exemplo n.º 9
0
 def __init__(self, length):
     self.address = pti.new("ptiNnzIndexVector *")
     PTI.ptiNewNnzIndexVector(self.address, length, length)
Exemplo n.º 10
0
 def __init__(self):
     self.address = pti.new("ptiSparseMatrix *")
     self.nthreads = (int)(os.popen('grep -c cores /proc/cpuinfo').read())
     self.map = None
Exemplo n.º 11
0
 def __init__(self, nrows, ncols):
     self.address = pti.new("ptiMatrix *")
     PTI.ptiNewMatrix(self.address, nrows, ncols)
     PTI.ptiConstantMatrix(self.address, 0)
Exemplo n.º 12
0
 def __init__(self):
     self.address = pti.new("ptiSparseMatrixCSR *")