Skip to content

Commit

Permalink
fix gamma on CPU and GPU
Browse files Browse the repository at this point in the history
  • Loading branch information
lvyufeng committed Oct 30, 2024
1 parent e9db14d commit ecdd3db
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mindnlp/core/ops/random.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""random op"""
import numpy as np
import mindspore
from mindspore import ops
from mindspore.ops._primitive_cache import _get_cache_prim
Expand Down Expand Up @@ -101,4 +102,6 @@ def randperm(n, seed=0, offset=0, dtype=mindspore.int64):
return randperm_op(mindspore.tensor([n]))

def gamma(shape, alpha, beta):
if DEVICE_TARGET != 'Ascend':
return mindspore.tensor(np.random.gamma(alpha, 1/beta, shape))
return ops.gamma(shape, alpha, beta)

0 comments on commit ecdd3db

Please sign in to comment.