Пример #1
0
 def testTwoOutputs(self):
     x = pkb.variable(m(3))
     f = '''function (I[N]) -> (O1, O2) { O1 = I; O2 = I; }'''
     result = pkb._Op("TwoOut", x.dtype, (None, ), f, {'I': x},
                      ['O1', 'O2'])
     output = result.eval()
     return 0
Пример #2
0
 def testAssignmentExceptions(self):
     A = pkb.variable(m(5, 1))
     B = pkb.variable(m(1, 5))
     f = """function (A[L, M], B[M, N]) -> (O) {
                O[i, k: L, N] = =(A[i, j] * B[j, k]);
            }"""
     # A * B has each entry a "sum" of exactly one product, and so assignment
     # is valid and should be the same as + aggregation.
     O = pkb._Op('assign_mul', A.dtype, (A.shape[0], B.shape[1]), f,
                 OrderedDict([('A', A), ('B', B)]), ['O']).eval()
     npt.assert_allclose(O, np.dot(m(5, 1), m(1, 5)))
     # B * A sums multiple products into one output entry, and so assignment
     # is not valid and should raise a multiple assignment error.
     with self.assertRaises(plaidml.exceptions.Unknown) as cm:
         pkb._Op('assign_mul', A.dtype, (A.shape[0], B.shape[1]), f,
                 OrderedDict([('A', B), ('B', A)]), ['O']).eval()
     self.assertTrue("Multiple assignment" in str(cm.exception))
Пример #3
0
 def testTileIdentity(self):
     x = pkb.variable(m(3))
     f = '''function (I[N]) -> (O) { O = I; }'''
     result = pkb._Op("TileIdent", x.dtype, (3, ), f, {'I': x}, ['O'])
     output = result.eval()
     return 0