Skip to content

fix diffusers pipeline h class ut #2086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mindnlp/core/_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,8 @@ def __contains__(self, item):
Tensor.bernoulli_ = ops.inplace_bernoulli
StubTensor.bernoulli_ = ops.inplace_bernoulli

Tensor.scatter_reduce = ops.scatter_reduce
StubTensor.scatter_reduce = ops.scatter_reduce

def _rebuild_from_type_v2(func, new_type, args, state):
ret = func(*args)
Expand Down
12 changes: 10 additions & 2 deletions mindnlp/core/ops/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from mindspore import ops
from mindspore.ops._primitive_cache import _get_cache_prim
from mindspore.ops.operations._grad_ops import StridedSliceGrad
from mindspore.ops.auto_generate.gen_ops_prim import inplace_scatter_src_reduce_op

from ..configs import use_pyboost, ON_ORANGE_PI
from .other import broadcast_tensors, finfo
Expand Down Expand Up @@ -220,8 +221,15 @@ def scatter_add(input, dim, index, src):
return mindspore.mint.scatter_add(input, dim, index, src)
return ops.tensor_scatter_elements(input, index, src, dim, 'add')

scatter_reduce_dict = {
'sum': 'add',
'amax': 'max',
'amin': 'min',
'mean': 'mean'
}
# scatter_reduce

def scatter_reduce(input, dim, index, src, reduce, *, include_self=True):
return inplace_scatter_src_reduce_op(input.clone(), dim, index, src, scatter_reduce_dict[reduce])

# scatter_nd_update
def scatter_nd_update(input, indices, update):
Expand Down Expand Up @@ -799,7 +807,7 @@ def strided_slice_update(input, begin, end, strides, update, begin_mask=0, end_m
# select_scatter
# slice_scatter
'scatter_add',
# scatter_reduce
'scatter_reduce',
'scatter_nd_update',
'scatter_update',
'split',
Expand Down
10 changes: 8 additions & 2 deletions mindnlp/core/ops/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,18 @@ def zeros(*size, dtype=None, device=None, requires_grad=False, **kwargs):
size = ((),)
if isinstance(size[0], (tuple, list)):
size = size[0]

new_size = ()
for s in size:
if not isinstance(s, int):
s = s.item()
new_size += (s,)
if use_pyboost() and has_zeros:
# if device == 'cpu':
# return mindspore.Tensor(np.zeros(size), dtype=dtype)
return mindspore.mint.zeros(size, dtype=dtype)
return mindspore.mint.zeros(new_size, dtype=dtype)
size = tuple(size)
return _zeros(size, dtype)
return _zeros(new_size, dtype)

# zeros_like
has_zeros_like = hasattr(mindspore.mint, 'zeros_like')
Expand Down
Loading