import HiParTIPy.Tensor as ten import sys from time import time name = sys.argv[1] coo = ten.COOTensor() coo.load(name) print("File Name: {}".format(name)) niters = int(sys.argv[2]) equ = int(niters / 100) for i in range(equ): coo.Kronecker(coo) start = time() for i in range(niters): coo.Kronecker(coo) end = time() print("Kronecker: Time = {},\n Time per Cycles = {}".format( end - start, (end - start) / niters)) niters *= 1 for i in range(equ): coo.KhatriRao(coo) start = time() for i in range(niters): coo.KhatriRao(coo) end = time()
import time as time import sys sys.path.insert(0, "./") import HiParTIPy.Tensor as ptiTen if len(sys.argv) < 2: sys.exit("Usage: python3 benchmarkPy/matrix/loadstore.py [.tns] [.tns]") tnsname = sys.argv[1] outname = sys.argv[2] print("Load Tensor from: {}".format(tnsname)) coo_in = ptiTen.COOTensor() coo_in.load(tnsname) # coo_in.status() print("Store Tensor to: {}".format(outname)) coo_in.dump(outname)
sys.path.insert(0, "./") import HiParTIPy.Tensor as ptiTen import HiParTIPy.Matrix as ptiMat if len(sys.argv) < 2: sys.exit( "Usage: python3 benchmarkPy/tensor/mttkrp.py [.tns] [mode] [rank] [niters]" ) name = sys.argv[1] mode = sys.argv[2] R = int(sys.argv[3]) niters = int(sys.argv[4]) print("Load Tensor from: {}".format(name)) coo = ptiTen.COOTensor() coo.load(name) nmodes = coo.nmodes() ndims_mode = coo.dim_mode(mode) input_mat = ptiMat.DenseMatrix(ndims_mode, R) input_mat.randomMatrix() coo.mulMatrix(mats, mode, type='serial', testing=True) start = time() for i in range(niters): coo.mulMatrix(mats, mode, type='serial', testing=True) end = time() print("TTM: Time = {},\n Time per Cycles = {}".format(end - start, (end - start) / niters))
import HiParTIPy.Tensor as ten import HiParTIPy.Matrix as mat import HiParTIPy.Vector as vec import HiParTIPy.Buffers as buff coo3d = ten.COOTensor() coo3d.load("data/tensors/3d-24.tns") print("HERE") coo3d.mulValue(4) coo3d.divValue(2) coo3d2 = ten.COOTensor() print("HERE") coo3d2.load("data/tensors/3d-24.tns") coo3d.addTensor(coo3d2, 1) print("HERE") coo3d.subtractTensor(coo3d, 1) coo3d.addTensor(coo3d2, 8) coo3d.mulValue(4) coo3d.subtractTensor(coo3d2, 10) print("HERE")