fix recursive import

This commit is contained in:
chenfei 2023-10-25 11:48:06 +08:00
parent 96eef1d0e2
commit 7cc7e890f6
4 changed files with 46 additions and 28 deletions

View File

@ -93,6 +93,7 @@
"mindspore/mindspore/python/mindspore/ops/function/math_func.py" "consider-using-enumerate"
"mindspore/mindspore/python/mindspore/ops/composite/multitype_ops/bitwise_and_impl.py" "too-many-function-args"
"mindspore/mindspore/python/mindspore/ops/composite/multitype_ops/bitwise_or_impl.py" "too-many-function-args"
"mindspore/mindspore/python/mindspore/ops_generate/gen_ops_inner_prim.py" "super-init-not-called"
# MindData
"mindspore/mindspore/python/mindspore/dataset/__init__.py" "redefined-builtin"

View File

@ -2729,31 +2729,6 @@ class CopyWithSlice(Primitive):
self.init_prim_io_names(inputs=['x', 'y'], outputs=['x'])
class DtypeToEnum(Primitive):
r"""
Convert mindspore dtype to enum.
Inputs:
- **dtype** (mindspore.dtype) - The data type.
Outputs:
An integer.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
"""
@prim_attr_register
def __init__(self):
"""Initialize"""
def __call__(self, dtype):
"""Run in PyNative mode"""
if not isinstance(dtype, typing.Type):
raise TypeError(f"For dtype_to_enum function, the input should be mindpsore dtype, but got {dtype}.")
return typing.type_to_type_id(dtype)
class MoeFFN(Primitive):
r"""
The MoeFFN computation is similar to Feed-Forward Network, it contains matmul + gelu + matmul.

View File

@ -14,10 +14,9 @@
# ============================================================================
"""Operator argument handle function."""
from mindspore.ops.operations import _inner_ops as inner
from mindspore.ops_generate.gen_ops_inner_prim import DtypeToEnum
ops_dtype_to_enum = inner.DtypeToEnum()
ops_dtype_to_enum = DtypeToEnum()
def to_kernel_size(kernel_size):

View File

@ -0,0 +1,43 @@
# Copyright 2023 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""Primitive defined for arg handler."""
from mindspore.ops.primitive import Primitive, prim_attr_register
from mindspore._c_expression import typing
class DtypeToEnum(Primitive):
r"""
Convert mindspore dtype to enum.
Inputs:
- **dtype** (mindspore.dtype) - The data type.
Outputs:
An integer.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
"""
@prim_attr_register
def __init__(self):
"""Initialize"""
def __call__(self, dtype):
"""Run in PyNative mode"""
if not isinstance(dtype, typing.Type):
raise TypeError(f"For dtype_to_enum function, the input should be mindpsore dtype, but got {dtype}.")
return typing.type_to_type_id(dtype)