def test_Gemm2D_float_2(self): shape_a = (8, 6) shape_b = (8, 6) shape_c = (8, 8) transA = 0 transB = 1 np_float_a = np.reshape(self.np_float_a, shape_a) np_float_b = np.reshape(self.np_float_b, shape_b) np_float_c = np.reshape(self.np_float_c, shape_c) dc_float_a = dc.reshape(self.dc_float_a, shape_a) dc_float_b = dc.reshape(self.dc_float_b, shape_b) dc_float_c = dc.reshape(self.dc_float_c, shape_c) npr = temp_gemm(np_float_a, np_float_b, np_float_c, self.alpha, self.beta, transA, transB) dcr = dc.gemm(dc_float_a, dc_float_b, dc_float_c, self.alpha, self.beta, transA, transB) np.testing.assert_allclose(npr.flatten(), np.array(dcr.data()).astype(np.float32), rtol=1e-3, atol=1e-3)
def test_Gemm2D_double_3(self): shape_a = (6, 8) shape_b = (6, 8) shape_c = (8, 8) transA = 1 transB = 0 np_double_a = np.reshape(self.np_double_a, shape_a) np_double_b = np.reshape(self.np_double_b, shape_b) np_double_c = np.reshape(self.np_double_c, shape_c) dc_double_a = dc.reshape(self.dc_double_a, shape_a) dc_double_b = dc.reshape(self.dc_double_b, shape_b) dc_double_c = dc.reshape(self.dc_double_c, shape_c) npr = temp_gemm(np_double_a, np_double_b, np_double_c, self.alpha, self.beta, transA, transB) dcr = dc.gemm(dc_double_a, dc_double_b, dc_double_c, self.alpha, self.beta, transA, transB) np.testing.assert_allclose(npr.flatten(), np.array(dcr.data()).astype(np.double), rtol=1e-3, atol=1e-3)