提交 bb125436 authored 作者: Alexander Matyasko's avatar Alexander Matyasko

Ensure that matrices are contiguous

上级 516e4e28
...@@ -400,6 +400,7 @@ class GpuMagmaSVD(COp): ...@@ -400,6 +400,7 @@ class GpuMagmaSVD(COp):
def make_node(self, A): def make_node(self, A):
ctx_name = infer_context_name(A) ctx_name = infer_context_name(A)
A = as_gpuarray_variable(A, ctx_name) A = as_gpuarray_variable(A, ctx_name)
A = gpu_contiguous(A)
if A.ndim != 2: if A.ndim != 2:
raise LinAlgError("Matrix rank error") raise LinAlgError("Matrix rank error")
assert A.dtype == 'float32' assert A.dtype == 'float32'
...@@ -484,13 +485,13 @@ class GpuMagmaMatrixInverse(GpuMagmaBase): ...@@ -484,13 +485,13 @@ class GpuMagmaMatrixInverse(GpuMagmaBase):
def clone_inplace(self): def clone_inplace(self):
return self.__class__(inplace=True) return self.__class__(inplace=True)
def make_node(self, x): def make_node(self, A):
ctx_name = infer_context_name(x) ctx_name = infer_context_name(A)
x = as_gpuarray_variable(x, ctx_name) A = as_gpuarray_variable(A, ctx_name)
assert x.dtype == 'float32' A = gpu_contiguous(A)
if x.ndim != 2: if A.ndim != 2:
raise LinAlgError("Matrix rank error") raise LinAlgError("Matrix rank error")
return theano.Apply(self, [x], [x.type()]) return theano.Apply(self, [A], [A.type()])
def get_params(self, node): def get_params(self, node):
return self.params_type.get_params(self, context=node.inputs[0].type.context) return self.params_type.get_params(self, context=node.inputs[0].type.context)
...@@ -603,6 +604,7 @@ class GpuMagmaEigh(GpuMagmaBase): ...@@ -603,6 +604,7 @@ class GpuMagmaEigh(GpuMagmaBase):
def make_node(self, A): def make_node(self, A):
ctx_name = infer_context_name(A) ctx_name = infer_context_name(A)
A = as_gpuarray_variable(A, ctx_name) A = as_gpuarray_variable(A, ctx_name)
A = gpu_contiguous(A)
if A.ndim != 2: if A.ndim != 2:
raise LinAlgError("Matrix rank error") raise LinAlgError("Matrix rank error")
if self.compute_v: if self.compute_v:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论