提交 771fdfd3 authored 作者: Alexander Matyasko's avatar Alexander Matyasko

Add test for gpu qr incomplete optimization

上级 a12a8d3e
...@@ -385,3 +385,11 @@ class TestMagma(unittest.TestCase): ...@@ -385,3 +385,11 @@ class TestMagma(unittest.TestCase):
isinstance(node.op, GpuMagmaQR) isinstance(node.op, GpuMagmaQR)
for node in fn.maker.fgraph.toposort() for node in fn.maker.fgraph.toposort()
]) ])
def test_gpu_qr_incomplete_opt(self):
A = theano.tensor.fmatrix("A")
fn = theano.function([A], qr(A, mode='r'), mode=mode_with_gpu)
assert any([
isinstance(node.op, GpuMagmaQR)
for node in fn.maker.fgraph.toposort()
])
...@@ -539,7 +539,7 @@ class QRIncomplete(Op): ...@@ -539,7 +539,7 @@ class QRIncomplete(Op):
Incomplete QR Decomposition. Incomplete QR Decomposition.
Computes the QR decomposition of a matrix. Computes the QR decomposition of a matrix.
Factor the matrix a as qr and return a single matrix. Factor the matrix a as qr and return a single matrix R.
""" """
...@@ -552,14 +552,14 @@ class QRIncomplete(Op): ...@@ -552,14 +552,14 @@ class QRIncomplete(Op):
def make_node(self, x): def make_node(self, x):
x = as_tensor_variable(x) x = as_tensor_variable(x)
assert x.ndim == 2, "The input of qr function should be a matrix." assert x.ndim == 2, "The input of qr function should be a matrix."
q = theano.tensor.matrix(dtype=x.dtype) r = theano.tensor.matrix(dtype=x.dtype)
return Apply(self, [x], [q]) return Apply(self, [x], [r])
def perform(self, node, inputs, outputs): def perform(self, node, inputs, outputs):
(x,) = inputs (x,) = inputs
(q,) = outputs (r,) = outputs
assert x.ndim == 2, "The input of qr function should be a matrix." assert x.ndim == 2, "The input of qr function should be a matrix."
q[0] = self._numop(x, self.mode) r[0] = self._numop(x, self.mode)
def qr(a, mode="reduced"): def qr(a, mode="reduced"):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论