diff --git a/benchmark/ascend/bert/src/bert_model.py b/benchmark/ascend/bert/src/bert_model.py index 23e17f6d6f6f87fd53ef4f358000effd4b284667..2923199fc7230614edd7b3435296ba7e81707bbd 100644 --- a/benchmark/ascend/bert/src/bert_model.py +++ b/benchmark/ascend/bert/src/bert_model.py @@ -340,7 +340,7 @@ class SaturateCast(nn.Cell): """ def __init__(self, src_type=mstype.float32, dst_type=mstype.float32): super(SaturateCast, self).__init__() - np_type = mstype.dtype_to_nptype(dst_type) + np_type = mstype._dtype_to_nptype(dst_type) # pylint: disable=protected-access self.tensor_min_type = float(np.finfo(np_type).min) self.tensor_max_type = float(np.finfo(np_type).max) @@ -451,7 +451,7 @@ class BertFlashAttention(nn.Cell): query_out = self.query_layer(from_tensor_2d) key_out = self.key_layer(to_tensor_2d) value_out = self.value_layer(to_tensor_2d) - #b, s, n, d + #b, s, n, d query_layer = self.reshape(query_out, (-1, shape_from, self.num_attention_heads, self.size_per_head)) query_layer = self.transpose(query_layer, self.trans_shape) key_layer = self.reshape(key_out, (-1, shape_from, self.num_attention_heads, self.size_per_head)) diff --git a/community/nlp/Roberta_Seq2Seq/src/roberta_model.py b/community/nlp/Roberta_Seq2Seq/src/roberta_model.py index d3f5b0a3f964826de66c713a303c38a088687820..e831ead2ee49e98fe475108b7bf63aaadefc2ef9 100644 --- a/community/nlp/Roberta_Seq2Seq/src/roberta_model.py +++ b/community/nlp/Roberta_Seq2Seq/src/roberta_model.py @@ -179,7 +179,7 @@ class SaturateCast(nn.Cell): def __init__(self, src_type=mstype.float32, dst_type=mstype.float32): super(SaturateCast, self).__init__() - np_type = mstype.dtype_to_nptype(dst_type) + np_type = mstype._dtype_to_nptype(dst_type) # pylint: disable=protected-access self.tensor_min_type = float(np.finfo(np_type).min) self.tensor_max_type = float(np.finfo(np_type).max) diff --git a/official/nlp/Bert/src/bert_model.py b/official/nlp/Bert/src/bert_model.py index ecc07b5b1de8c9fa42a1ab5d53685b73f88cf1c0..3d50b026b1c755f49c25df3dd4e85ffcbec21217 100644 --- a/official/nlp/Bert/src/bert_model.py +++ b/official/nlp/Bert/src/bert_model.py @@ -339,7 +339,7 @@ class SaturateCast(nn.Cell): """ def __init__(self, src_type=mstype.float32, dst_type=mstype.float32): super(SaturateCast, self).__init__() - np_type = mstype.dtype_to_nptype(dst_type) + np_type = mstype._dtype_to_nptype(dst_type) # pylint: disable=protected-access self.tensor_min_type = float(np.finfo(np_type).min) self.tensor_max_type = float(np.finfo(np_type).max) diff --git a/official/nlp/Bert_thor/src/bert_model.py b/official/nlp/Bert_thor/src/bert_model.py index 9a5605919b7513cfaf28ff0956011e0fe612982a..4390df458dd5f13456786fc2dcd230d94d7694a1 100644 --- a/official/nlp/Bert_thor/src/bert_model.py +++ b/official/nlp/Bert_thor/src/bert_model.py @@ -341,7 +341,7 @@ class SaturateCast(nn.Cell): """ def __init__(self, src_type=mstype.float32, dst_type=mstype.float32): super(SaturateCast, self).__init__() - np_type = mstype.dtype_to_nptype(dst_type) + np_type = mstype._dtype_to_nptype(dst_type) # pylint: disable=protected-access self.tensor_min_type = float(np.finfo(np_type).min) self.tensor_max_type = float(np.finfo(np_type).max) diff --git a/research/nlp/DYR/src/bert_model.py b/research/nlp/DYR/src/bert_model.py index ec9931881927d26c87ff814f797f7979779d0a28..b176000d3dc09b15882d2a018a7b82be98e3487f 100644 --- a/research/nlp/DYR/src/bert_model.py +++ b/research/nlp/DYR/src/bert_model.py @@ -341,7 +341,7 @@ class SaturateCast(nn.Cell): """ def __init__(self, src_type=mstype.float32, dst_type=mstype.float32): super(SaturateCast, self).__init__() - np_type = mstype.dtype_to_nptype(dst_type) + np_type = mstype._dtype_to_nptype(dst_type) # pylint: disable=protected-access self.tensor_min_type = float(np.finfo(np_type).min) self.tensor_max_type = float(np.finfo(np_type).max) diff --git a/research/nlp/albert/src/albert_model.py b/research/nlp/albert/src/albert_model.py index d33284f4115ed0c5c719bbadc9865e8bc71a8029..e267ce4730045fd0822bcdc98b02919eaeafd556 100644 --- a/research/nlp/albert/src/albert_model.py +++ b/research/nlp/albert/src/albert_model.py @@ -371,7 +371,7 @@ class SaturateCast(nn.Cell): def __init__(self, src_type=mstype.float32, dst_type=mstype.float32): super(SaturateCast, self).__init__() - np_type = mstype.dtype_to_nptype(dst_type) + np_type = mstype._dtype_to_nptype(dst_type) # pylint: disable=protected-access self.tensor_min_type = Tensor(np.finfo(np_type).min, dtype=src_type) self.tensor_max_type = Tensor(np.finfo(np_type).max, dtype=src_type) diff --git a/research/nlp/cpm/src/model_cpm.py b/research/nlp/cpm/src/model_cpm.py index cccf1b991a13b69f9973310b20423271afd40115..be16acfeaf73b02d6d55fe626ce33ab585efdc38 100644 --- a/research/nlp/cpm/src/model_cpm.py +++ b/research/nlp/cpm/src/model_cpm.py @@ -19,7 +19,7 @@ from mindspore.train.callback import RunContext from mindspore import context from mindspore.context import ParallelMode from mindspore import Model, connect_network_with_dataset -from mindspore.common.dtype import pytype_to_dtype +from mindspore.common.dtype import _pytype_to_dtype from mindspore._c_expression import init_exec_dataset from mindspore.train.train_thor.dataset_helper import DatasetHelper @@ -36,7 +36,7 @@ def _convert_type(types): """ ms_types = [] for np_type in types: - ms_type = pytype_to_dtype(np_type) + ms_type = _pytype_to_dtype(np_type) ms_types.append(ms_type) return ms_types diff --git a/research/nlp/dgu/src/bert_model.py b/research/nlp/dgu/src/bert_model.py index 0210a719d505dabe9834b7b50e8011c34d493e2c..2c6a22946b047afdda36e74a873b620cefd2f0e0 100644 --- a/research/nlp/dgu/src/bert_model.py +++ b/research/nlp/dgu/src/bert_model.py @@ -349,7 +349,7 @@ class SaturateCast(nn.Cell): """ def __init__(self, src_type=mstype.float32, dst_type=mstype.float32): super(SaturateCast, self).__init__() - np_type = mstype.dtype_to_nptype(dst_type) + np_type = mstype._dtype_to_nptype(dst_type) # pylint: disable=protected-access self.tensor_min_type = float(np.finfo(np_type).min) self.tensor_max_type = float(np.finfo(np_type).max) diff --git a/research/nlp/emotect/src/ernie_model.py b/research/nlp/emotect/src/ernie_model.py index 0946abd3c5f2872cf0b6711e2dc0e55a56477695..864cfde96ffb65a8e04216a44a654a41d1561907 100644 --- a/research/nlp/emotect/src/ernie_model.py +++ b/research/nlp/emotect/src/ernie_model.py @@ -334,7 +334,7 @@ class SaturateCast(nn.Cell): """ def __init__(self, src_type=mstype.float32, dst_type=mstype.float32): super(SaturateCast, self).__init__() - np_type = mstype.dtype_to_nptype(dst_type) + np_type = mstype._dtype_to_nptype(dst_type) # pylint: disable=protected-access self.tensor_min_type = float(np.finfo(np_type).min) self.tensor_max_type = float(np.finfo(np_type).max) diff --git a/research/nlp/ernie/src/ernie_model.py b/research/nlp/ernie/src/ernie_model.py index b6c53200ce5105fe55c59b29ab1ccfecbe6d96d1..83c7cab06d8a13b0e05ce29ce85ca24013fe2458 100644 --- a/research/nlp/ernie/src/ernie_model.py +++ b/research/nlp/ernie/src/ernie_model.py @@ -333,7 +333,7 @@ class SaturateCast(nn.Cell): """ def __init__(self, src_type=mstype.float32, dst_type=mstype.float32): super(SaturateCast, self).__init__() - np_type = mstype.dtype_to_nptype(dst_type) + np_type = mstype._dtype_to_nptype(dst_type) # pylint: disable=protected-access self.tensor_min_type = float(np.finfo(np_type).min) self.tensor_max_type = float(np.finfo(np_type).max) diff --git a/research/nlp/ktnet/src/bert.py b/research/nlp/ktnet/src/bert.py index de70995ebf15cde974e60364586164ed1549710f..2aae158188f69d13b8d85f31988556d845bba0a5 100644 --- a/research/nlp/ktnet/src/bert.py +++ b/research/nlp/ktnet/src/bert.py @@ -356,7 +356,7 @@ class SaturateCast(nn.Cell): def __init__(self, src_type=mstype.float32, dst_type=mstype.float32): super(SaturateCast, self).__init__() - np_type = mstype.dtype_to_nptype(dst_type) + np_type = mstype._dtype_to_nptype(dst_type) # pylint: disable=protected-access self.tensor_min_type = float(np.finfo(np_type).min) self.tensor_max_type = float(np.finfo(np_type).max) diff --git a/research/nlp/senta/src/bert_model.py b/research/nlp/senta/src/bert_model.py index e28db53c80074be8bc473505ae342f2b3fa4e5e1..f3366f83cc39e45e825f43523cc8a8082b1fe57d 100644 --- a/research/nlp/senta/src/bert_model.py +++ b/research/nlp/senta/src/bert_model.py @@ -349,7 +349,7 @@ class SaturateCast(nn.Cell): """ def __init__(self, src_type=mstype.float32, dst_type=mstype.float32): super(SaturateCast, self).__init__() - np_type = mstype.dtype_to_nptype(dst_type) + np_type = mstype._dtype_to_nptype(dst_type) # pylint: disable=protected-access self.tensor_min_type = float(np.finfo(np_type).min) self.tensor_max_type = float(np.finfo(np_type).max) diff --git a/research/nlp/soft_masked_bert/src/bert_model.py b/research/nlp/soft_masked_bert/src/bert_model.py index 1b2dbd5315f51ab266c201ba9b0ddceeace7eb6a..d9e11ea49d7730c6683c54fffae1918a2f108784 100644 --- a/research/nlp/soft_masked_bert/src/bert_model.py +++ b/research/nlp/soft_masked_bert/src/bert_model.py @@ -400,7 +400,7 @@ class SaturateCast(nn.Cell): """ def __init__(self, src_type=mstype.float32, dst_type=mstype.float32): super(SaturateCast, self).__init__() - np_type = mstype.dtype_to_nptype(dst_type) + np_type = mstype._dtype_to_nptype(dst_type) # pylint: disable=protected-access self.tensor_min_type = float(np.finfo(np_type).min) self.tensor_max_type = float(np.finfo(np_type).max) diff --git a/research/nlp/ternarybert/src/tinybert_model.py b/research/nlp/ternarybert/src/tinybert_model.py index cf8290bec46f27fce23ac213527e36725f1cd601..6f3bb21c0e269103b47c744f828f382027fb196a 100644 --- a/research/nlp/ternarybert/src/tinybert_model.py +++ b/research/nlp/ternarybert/src/tinybert_model.py @@ -564,7 +564,7 @@ class SaturateCast(nn.Cell): def __init__(self, src_type=mstype.float32, dst_type=mstype.float32): super(SaturateCast, self).__init__() - np_type = mstype.dtype_to_nptype(dst_type) + np_type = mstype._dtype_to_nptype(dst_type) # pylint: disable=protected-access min_type = np.finfo(np_type).min max_type = np.finfo(np_type).max self.tensor_min_type = Tensor([min_type], dtype=src_type) diff --git a/research/nlp/tinybert/src/tinybert_model.py b/research/nlp/tinybert/src/tinybert_model.py index 875cc6048e8e6a2e806991fbda1099cdec096bad..1b4cc2de9821c9c42cfeb594bf06575f8284bdc5 100644 --- a/research/nlp/tinybert/src/tinybert_model.py +++ b/research/nlp/tinybert/src/tinybert_model.py @@ -298,7 +298,7 @@ class SaturateCast(nn.Cell): """ def __init__(self, src_type=mstype.float32, dst_type=mstype.float32): super(SaturateCast, self).__init__() - np_type = mstype.dtype_to_nptype(dst_type) + np_type = mstype._dtype_to_nptype(dst_type) # pylint: disable=protected-access min_type = np.finfo(np_type).min max_type = np.finfo(np_type).max self.tensor_min_type = Tensor([min_type], dtype=src_type)