提交 a8dd3186 authored 作者: Frederic Bastien's avatar Frederic Bastien

Add ones_like to the Scalar interface.

上级 d321401b
......@@ -790,6 +790,12 @@ class _scalar_py_operators:
dtype = str(self.type.dtype)
return second(self, ScalarConstant(get_scalar_type(dtype), 0))
def ones_like(self, dtype=None):
# The second is needed for Elemwise ops to work right
if dtype is None:
dtype = str(self.type.dtype)
return second(self, ScalarConstant(get_scalar_type(dtype), 1))
def astype(self, dtype):
return cast(self, dtype)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论