def addbmm(self, tensor2, mat, beta=1, alpha=1): """Performs a batch matrix-matrix product of matrices stored in batch1(tensor1) and batch2(tensor2), with a reduced add step (all matrix multiplications get accumulated along the first dimension). mat is added to the final result. res=(beta∗M)+(alpha∗sum(batch1i@batch2i, i=0, b)) * batch1 and batch2 must be 3D Tensors each containing the same number of matrices.""" return syft.addbmm(self, tensor2, mat, beta, alpha)
def test_addbmm(self): t1 = TensorBase(np.array([[[3, 4], [5, 6]], [[7, 8], [1, 2]]])) t2 = TensorBase(np.array([[[3, 5], [5, 7]], [[7, 9], [1, 3]]])) mat = TensorBase(np.array([[2, 3], [3, 4]])) out = syft.addbmm(t1, t2, mat, beta=2, alpha=2) self.assertTrue(np.array_equal(out.data, [[176, 266], [114, 172]]))