!5652 add type ones_like op

Merge pull request !5652 from riemann_penn/add_type_ones_like_op
pull/5652/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit 5e3e0a3386

@ -368,8 +368,8 @@ def get_bprop_sparse_gather_v2(self):
x_tail_shp = x_shp[1:]
values_shape = indices_size + x_tail_shp
values = reshape(dout, values_shape)
indices = reshape(indices, indices_size)
return RowTensor(indices, values, x_shp), zeros_like(indices), zeros_like(axis)
indices_new = reshape(indices, indices_size)
return RowTensor(indices_new, values, x_shp), zeros_like(indices), zeros_like(axis)
if F.rank(dout) == 0:
dout = P.ExpandDims()(dout, -1)
if F.rank(indices) == 0:

@ -29,6 +29,12 @@ using ".register" decorator.
"""
@ones_like_leaf.register("TypeType")
def _ones_like_type_type(x):
"""Returns x because x is a type. This is usually used in backprop progress."""
return x
@ones_like_leaf.register("Number")
def _ones_like_scalar(x):
"""Returns 1 which has the same dtype as x where x is a scalar."""

Loading…
Cancel
Save