提交 96363cb9 authored 作者: David Warde-Farley's avatar David Warde-Farley

Fix tile op implementation.

Raise a proper error when reps is not a constant (since a tensor value is not supported by this implementation, as it is) and also force x.ndim == len(reps), since bad things happen if it's not the case.
上级 bd202537
......@@ -4750,10 +4750,21 @@ def tile(x, reps, ndim=None):
Tile input array `x` according to `reps`. See the docstring of `numpy.tile`
for details.
Currently, `reps` must be a constant.
TODO: expand this.
"""
if len(reps) != x.ndim:
raise ValueError("len(reps) != x.ndim not currently supported")
if not hasattr(tile, 'op'):
tile.op = {}
try:
assert builtin_all([int(i) == i for i in iter(reps)])
except (TypeError, AssertionError):
raise ValueError("reps argument to tile must be a constant (e.g. "
"tuple, list of integers)")
if ndim is None:
ndim = len(reps)
......@@ -5670,9 +5681,15 @@ def outer(x, y):
y.dimshuffle('x', 0))
builtin_any = any
def any(x, axis=None):
return elemwise.Any(axis)(x)
builtin_all = all
def all(x, axis=None):
return elemwise.All(axis)(x)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论