diff --git a/mindspore/model_zoo/Bert_NEZHA/bert_model.py b/mindspore/model_zoo/Bert_NEZHA/bert_model.py index d7f9355b3c4c12d5c385df564f9919b78ac9a122..b9c6e8c4a1f37daa9ab4ffe9a1a3db72b4130044 100644 --- a/mindspore/model_zoo/Bert_NEZHA/bert_model.py +++ b/mindspore/model_zoo/Bert_NEZHA/bert_model.py @@ -194,7 +194,7 @@ class EmbeddingPostprocessor(nn.Cell): self.dropout = nn.Dropout(1 - dropout_prob) self.gather = P.GatherV2() self.use_relative_positions = use_relative_positions - self.slice = P.Slice() + self.slice = P.StridedSlice() self.full_position_embeddings = Parameter(initializer (TruncatedNormal(initializer_range), [max_position_embeddings, @@ -216,7 +216,7 @@ class EmbeddingPostprocessor(nn.Cell): output += token_type_embeddings if not self.use_relative_positions: _, seq, width = self.shape - position_embeddings = self.slice(self.full_position_embeddings, [0, 0], [seq, width]) + position_embeddings = self.slice(self.full_position_embeddings, (0, 0), (seq, width), (1, 1)) position_embeddings = self.reshape(position_embeddings, (1, seq, width)) output += position_embeddings output = self.layernorm(output)