提交 74e57be8 authored 作者: ChienliMa's avatar ChienliMa

Add fill_diagonal_offet()

上级 28496857
...@@ -754,11 +754,15 @@ class FillDiagonalOffset(gof.Op): ...@@ -754,11 +754,15 @@ class FillDiagonalOffset(gof.Op):
elif val.ndim != 0: elif val.ndim != 0:
raise TypeError('%s: second parameter must be a scalar'\ raise TypeError('%s: second parameter must be a scalar'\
% self.__class__.__name__) % self.__class__.__name__)
elif offset.ndim != 0:
raise TypeError('%s: third parameter must be a scalar'\
% self.__class__.__name__)
val = tensor.cast(val, dtype=scalar.upcast(a.dtype, val.dtype)) val = tensor.cast(val, dtype=scalar.upcast(a.dtype, val.dtype))
if val.dtype != a.dtype: if val.dtype != a.dtype:
raise TypeError('%s: type of second parameter must be compatible' raise TypeError('%s: type of second parameter must be compatible'
' with first\'s' % self.__class__.__name__) ' with first\'s' % self.__class__.__name__)
return gof.Apply(self, [a, val, offset], [a.type()]) return gof.Apply(self, [a, val, offset], [a.type()])
def perform(self, node, inputs, output_storage): def perform(self, node, inputs, output_storage):
...@@ -769,7 +773,7 @@ class FillDiagonalOffset(gof.Op): ...@@ -769,7 +773,7 @@ class FillDiagonalOffset(gof.Op):
# offset should be an integer # offset should be an integer
if offset % 1 != 0: if offset % 1 != 0:
raise TypeError('%s: third parameter must be an integer'\ raise ValueError('%s: third parameter must be an integer'\
% self.__class__.__name__) % self.__class__.__name__)
# numpy.fill_diagonal up to date(including 1.6.2) have a # numpy.fill_diagonal up to date(including 1.6.2) have a
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论