1be168c0dSopenharmony_ciFrom 464a6a0499d215d5c624041d6ce255b860a54a35 Mon Sep 17 00:00:00 2001
2be168c0dSopenharmony_ciFrom: j00575040 <jianghui58@huawei.com>
3be168c0dSopenharmony_ciDate: Tue, 9 Apr 2024 21:34:17 +0800
4be168c0dSopenharmony_ciSubject: [PATCH] fix argminmax int bug && support swish int8 && fix VAD asan
5be168c0dSopenharmony_ci bug
6be168c0dSopenharmony_ci
7be168c0dSopenharmony_ci---
8be168c0dSopenharmony_ci mindspore/lite/src/litert/kernel/cpu/BUILD.gn |  1 +
9be168c0dSopenharmony_ci .../src/litert/kernel/cpu/base/custom_base.cc | 14 ++--
10be168c0dSopenharmony_ci .../litert/kernel/cpu/int8/activation_int8.cc |  4 ++
11be168c0dSopenharmony_ci .../litert/kernel/cpu/int8/argminmax_int8.cc  | 35 +++++-----
12be168c0dSopenharmony_ci .../src/litert/kernel/cpu/int8/sigmoid_int8.h |  2 +-
13be168c0dSopenharmony_ci .../src/litert/kernel/cpu/int8/swish_int8.cc  | 67 +++++++++++++++++++
14be168c0dSopenharmony_ci .../src/litert/kernel/cpu/int8/swish_int8.h   | 38 +++++++++++
15be168c0dSopenharmony_ci mindspore/lite/src/litert/scheduler.cc        |  9 ++-
16be168c0dSopenharmony_ci 8 files changed, 139 insertions(+), 31 deletions(-)
17be168c0dSopenharmony_ci create mode 100644 mindspore/lite/src/litert/kernel/cpu/int8/swish_int8.cc
18be168c0dSopenharmony_ci create mode 100644 mindspore/lite/src/litert/kernel/cpu/int8/swish_int8.h
19be168c0dSopenharmony_ci
20be168c0dSopenharmony_cidiff --git a/mindspore/lite/src/litert/kernel/cpu/BUILD.gn b/mindspore/lite/src/litert/kernel/cpu/BUILD.gn
21be168c0dSopenharmony_ciindex 7b813314..297fc6f6 100644
22be168c0dSopenharmony_ci--- a/mindspore/lite/src/litert/kernel/cpu/BUILD.gn
23be168c0dSopenharmony_ci+++ b/mindspore/lite/src/litert/kernel/cpu/BUILD.gn
24be168c0dSopenharmony_ci@@ -245,6 +245,7 @@ int8_kernel_sources = [
25be168c0dSopenharmony_ci     "int8/split_int8.cc",
26be168c0dSopenharmony_ci     "int8/squeeze_int8.cc",
27be168c0dSopenharmony_ci     "int8/sub_int8.cc",
28be168c0dSopenharmony_ci+    "int8/swish_int8.cc",
29be168c0dSopenharmony_ci     "int8/tanh_int8.cc",
30be168c0dSopenharmony_ci     "int8/topk_int8.cc",
31be168c0dSopenharmony_ci     "int8/transpose_int8.cc",
32be168c0dSopenharmony_cidiff --git a/mindspore/lite/src/litert/kernel/cpu/base/custom_base.cc b/mindspore/lite/src/litert/kernel/cpu/base/custom_base.cc
33be168c0dSopenharmony_ciindex 9921e063..0459c417 100644
34be168c0dSopenharmony_ci--- a/mindspore/lite/src/litert/kernel/cpu/base/custom_base.cc
35be168c0dSopenharmony_ci+++ b/mindspore/lite/src/litert/kernel/cpu/base/custom_base.cc
36be168c0dSopenharmony_ci@@ -28,19 +28,15 @@ using mindspore::lite::RET_OK;
37be168c0dSopenharmony_ci using mindspore::schema::PrimitiveType_Custom;
38be168c0dSopenharmony_ci 
39be168c0dSopenharmony_ci namespace mindspore::kernel {
40be168c0dSopenharmony_ci-int CustomBaseCPUKernel::Prepare() {
41be168c0dSopenharmony_ci-  return RET_OK;
42be168c0dSopenharmony_ci-}
43be168c0dSopenharmony_ci+int CustomBaseCPUKernel::Prepare() { return RET_OK; }
44be168c0dSopenharmony_ci 
45be168c0dSopenharmony_ci-int CustomBaseCPUKernel::ReSize() {
46be168c0dSopenharmony_ci-  return RET_OK;
47be168c0dSopenharmony_ci-}
48be168c0dSopenharmony_ci+int CustomBaseCPUKernel::ReSize() { return RET_OK; }
49be168c0dSopenharmony_ci 
50be168c0dSopenharmony_ci-int CustomBaseCPUKernel::Run() {
51be168c0dSopenharmony_ci-  return RET_OK;
52be168c0dSopenharmony_ci-}
53be168c0dSopenharmony_ci+int CustomBaseCPUKernel::Run() { return RET_OK; }
54be168c0dSopenharmony_ci 
55be168c0dSopenharmony_ci REG_KERNEL(kCPU, kNumberTypeInt32, PrimType_Inner_ThirdPartyModel, LiteKernelCreator<CustomBaseCPUKernel>)
56be168c0dSopenharmony_ci REG_KERNEL(kCPU, kNumberTypeFloat32, PrimType_Inner_ThirdPartyModel, LiteKernelCreator<CustomBaseCPUKernel>)
57be168c0dSopenharmony_ci+REG_KERNEL(kCPU, kNumberTypeInt8, PrimType_Inner_ThirdPartyModel, LiteKernelCreator<CustomBaseCPUKernel>)
58be168c0dSopenharmony_ci+REG_KERNEL(kCPU, kNumberTypeUInt8, PrimType_Inner_ThirdPartyModel, LiteKernelCreator<CustomBaseCPUKernel>)
59be168c0dSopenharmony_ci REG_KERNEL(kCPU, kNumberTypeBool, PrimType_Inner_ThirdPartyModel, LiteKernelCreator<CustomBaseCPUKernel>)
60be168c0dSopenharmony_ci }  // namespace mindspore::kernel
61be168c0dSopenharmony_cidiff --git a/mindspore/lite/src/litert/kernel/cpu/int8/activation_int8.cc b/mindspore/lite/src/litert/kernel/cpu/int8/activation_int8.cc
62be168c0dSopenharmony_ciindex 9bc410e7..10b6cd5a 100644
63be168c0dSopenharmony_ci--- a/mindspore/lite/src/litert/kernel/cpu/int8/activation_int8.cc
64be168c0dSopenharmony_ci+++ b/mindspore/lite/src/litert/kernel/cpu/int8/activation_int8.cc
65be168c0dSopenharmony_ci@@ -16,6 +16,7 @@
66be168c0dSopenharmony_ci 
67be168c0dSopenharmony_ci #include "src/litert/kernel/cpu/int8/relux_int8.h"
68be168c0dSopenharmony_ci #include "src/litert/kernel/cpu/int8/hswish_int8.h"
69be168c0dSopenharmony_ci+#include "src/litert/kernel/cpu/int8/swish_int8.h"
70be168c0dSopenharmony_ci #include "src/litert/kernel/cpu/int8/sigmoid_int8.h"
71be168c0dSopenharmony_ci #include "src/litert/kernel/cpu/int8/tanh_int8.h"
72be168c0dSopenharmony_ci #include "src/litert/kernel/cpu/int8/leaky_relu_int8.h"
73be168c0dSopenharmony_ci@@ -50,6 +51,9 @@ kernel::LiteKernel *CpuActivationInt8KernelCreator(const std::vector<lite::Tenso
74be168c0dSopenharmony_ci     case schema::ActivationType_HSWISH:
75be168c0dSopenharmony_ci       kernel = new (std::nothrow) HswishInt8CPUKernel(parameter, inputs, outputs, ctx);
76be168c0dSopenharmony_ci       break;
77be168c0dSopenharmony_ci+    case schema::ActivationType_SWISH:
78be168c0dSopenharmony_ci+      kernel = new (std::nothrow) SwishInt8CPUKernel(parameter, inputs, outputs, ctx);
79be168c0dSopenharmony_ci+      break;
80be168c0dSopenharmony_ci     case schema::ActivationType_SIGMOID:
81be168c0dSopenharmony_ci       kernel = new (std::nothrow) SigmoidInt8CPUKernel(parameter, inputs, outputs, ctx);
82be168c0dSopenharmony_ci       break;
83be168c0dSopenharmony_cidiff --git a/mindspore/lite/src/litert/kernel/cpu/int8/argminmax_int8.cc b/mindspore/lite/src/litert/kernel/cpu/int8/argminmax_int8.cc
84be168c0dSopenharmony_ciindex b5018909..7cb872d9 100644
85be168c0dSopenharmony_ci--- a/mindspore/lite/src/litert/kernel/cpu/int8/argminmax_int8.cc
86be168c0dSopenharmony_ci+++ b/mindspore/lite/src/litert/kernel/cpu/int8/argminmax_int8.cc
87be168c0dSopenharmony_ci@@ -47,12 +47,6 @@ int ArgMinMaxInt8CPUKernel::Prepare() {
88be168c0dSopenharmony_ci   CHECK_LESS_RETURN(out_tensors_.size(), C1NUM);
89be168c0dSopenharmony_ci   CHECK_NULL_RETURN(in_tensors_[0]);
90be168c0dSopenharmony_ci   CHECK_NULL_RETURN(out_tensors_[0]);
91be168c0dSopenharmony_ci-  if (in_tensors_[0]->data_type() != mindspore::kNumberTypeInt8 ||
92be168c0dSopenharmony_ci-      out_tensors_[0]->data_type() != mindspore::kNumberTypeInt8) {
93be168c0dSopenharmony_ci-    MS_LOG(ERROR) << "Datatype error, input0 data_type is " << in_tensors_[0]->data_type() << ", output data_type is "
94be168c0dSopenharmony_ci-                  << out_tensors_[0]->data_type();
95be168c0dSopenharmony_ci-    return RET_ERROR;
96be168c0dSopenharmony_ci-  }
97be168c0dSopenharmony_ci   in_quant_arg_ = reinterpret_cast<QuantArg *>(malloc(sizeof(QuantArg)));
98be168c0dSopenharmony_ci   if (in_quant_arg_ == nullptr) {
99be168c0dSopenharmony_ci     MS_LOG(ERROR) << "Malloc QuantArg for argmin or argmax int8 op failed!";
100be168c0dSopenharmony_ci@@ -64,18 +58,7 @@ int ArgMinMaxInt8CPUKernel::Prepare() {
101be168c0dSopenharmony_ci   in_quant_arg_->scale_ = in_quant_args.front().scale;
102be168c0dSopenharmony_ci   in_quant_arg_->zp_ = in_quant_args.front().zeroPoint;
103be168c0dSopenharmony_ci 
104be168c0dSopenharmony_ci-  auto *out_tensor = out_tensors_.at(kOutputIndex);
105be168c0dSopenharmony_ci-  auto out_quant_args = out_tensor->quant_params();
106be168c0dSopenharmony_ci-  CHECK_LESS_RETURN(out_quant_args.size(), 1);
107be168c0dSopenharmony_ci-  out_quant_arg_ = reinterpret_cast<QuantArg *>(malloc(sizeof(QuantArg)));
108be168c0dSopenharmony_ci-  out_quant_arg_->scale_ = out_quant_args.front().scale;
109be168c0dSopenharmony_ci-  out_quant_arg_->zp_ = out_quant_args.front().zeroPoint;
110be168c0dSopenharmony_ci-  if (out_quant_arg_ == nullptr) {
111be168c0dSopenharmony_ci-    MS_LOG(ERROR) << "Malloc QuantArg for argmin or argmax int8 op failed!";
112be168c0dSopenharmony_ci-    return RET_ERROR;
113be168c0dSopenharmony_ci-  }
114be168c0dSopenharmony_ci-
115be168c0dSopenharmony_ci-  compute_param_ = reinterpret_cast<ArgMinMaxComputeParam *>(sizeof(ArgMinMaxComputeParam));
116be168c0dSopenharmony_ci+  compute_param_ = reinterpret_cast<ArgMinMaxComputeParam *>(malloc(sizeof(ArgMinMaxComputeParam)));
117be168c0dSopenharmony_ci   if (compute_param_ == nullptr) {
118be168c0dSopenharmony_ci     MS_LOG(ERROR) << "Malloc ArgMinMaxComputeParam for argmin or argmax int8 op failed!";
119be168c0dSopenharmony_ci     return RET_ERROR;
120be168c0dSopenharmony_ci@@ -87,6 +70,22 @@ int ArgMinMaxInt8CPUKernel::Prepare() {
121be168c0dSopenharmony_ci   compute_param_->out_value_ = param->out_value_;
122be168c0dSopenharmony_ci   compute_param_->keep_dims_ = param->keep_dims_;
123be168c0dSopenharmony_ci 
124be168c0dSopenharmony_ci+  out_quant_arg_ = reinterpret_cast<QuantArg *>(malloc(sizeof(QuantArg)));
125be168c0dSopenharmony_ci+  if (out_quant_arg_ == nullptr) {
126be168c0dSopenharmony_ci+    MS_LOG(ERROR) << "Malloc QuantArg for argmin or argmax int8 op failed!";
127be168c0dSopenharmony_ci+    return RET_ERROR;
128be168c0dSopenharmony_ci+  }
129be168c0dSopenharmony_ci+  if (out_tensors_.size() == Num2 || compute_param_->out_value_) {
130be168c0dSopenharmony_ci+    auto *out_tensor = out_tensors_.at(kOutputIndex);
131be168c0dSopenharmony_ci+    auto out_quant_args = out_tensor->quant_params();
132be168c0dSopenharmony_ci+    CHECK_LESS_RETURN(out_quant_args.size(), 1);
133be168c0dSopenharmony_ci+    out_quant_arg_->scale_ = out_quant_args.front().scale;
134be168c0dSopenharmony_ci+    out_quant_arg_->zp_ = out_quant_args.front().zeroPoint;
135be168c0dSopenharmony_ci+  } else {  // set default quant value
136be168c0dSopenharmony_ci+    out_quant_arg_->scale_ = 1.0f;
137be168c0dSopenharmony_ci+    out_quant_arg_->zp_ = 0;
138be168c0dSopenharmony_ci+  }
139be168c0dSopenharmony_ci+
140be168c0dSopenharmony_ci   if (!InferShapeDone()) {
141be168c0dSopenharmony_ci     return RET_OK;
142be168c0dSopenharmony_ci   }
143be168c0dSopenharmony_cidiff --git a/mindspore/lite/src/litert/kernel/cpu/int8/sigmoid_int8.h b/mindspore/lite/src/litert/kernel/cpu/int8/sigmoid_int8.h
144be168c0dSopenharmony_ciindex 1f383ae6..9080852f 100644
145be168c0dSopenharmony_ci--- a/mindspore/lite/src/litert/kernel/cpu/int8/sigmoid_int8.h
146be168c0dSopenharmony_ci+++ b/mindspore/lite/src/litert/kernel/cpu/int8/sigmoid_int8.h
147be168c0dSopenharmony_ci@@ -34,7 +34,7 @@ class SigmoidInt8CPUKernel : public LiteKernel {
148be168c0dSopenharmony_ci   int Run() override;
149be168c0dSopenharmony_ci   int DoActivation(int task_id);
150be168c0dSopenharmony_ci 
151be168c0dSopenharmony_ci- private:
152be168c0dSopenharmony_ci+ protected:
153be168c0dSopenharmony_ci   int8_t table_list_[256]{0};
154be168c0dSopenharmony_ci };
155be168c0dSopenharmony_ci }  // namespace mindspore::kernel
156be168c0dSopenharmony_cidiff --git a/mindspore/lite/src/litert/kernel/cpu/int8/swish_int8.cc b/mindspore/lite/src/litert/kernel/cpu/int8/swish_int8.cc
157be168c0dSopenharmony_cinew file mode 100644
158be168c0dSopenharmony_ciindex 00000000..501793af
159be168c0dSopenharmony_ci--- /dev/null
160be168c0dSopenharmony_ci+++ b/mindspore/lite/src/litert/kernel/cpu/int8/swish_int8.cc
161be168c0dSopenharmony_ci@@ -0,0 +1,67 @@
162be168c0dSopenharmony_ci+/**
163be168c0dSopenharmony_ci+ * Copyright 2024 Huawei Technologies Co., Ltd
164be168c0dSopenharmony_ci+ *
165be168c0dSopenharmony_ci+ * Licensed under the Apache License, Version 2.0 (the "License");
166be168c0dSopenharmony_ci+ * you may not use this file except in compliance with the License.
167be168c0dSopenharmony_ci+ * You may obtain a copy of the License at
168be168c0dSopenharmony_ci+ *
169be168c0dSopenharmony_ci+ * http://www.apache.org/licenses/LICENSE-2.0
170be168c0dSopenharmony_ci+ *
171be168c0dSopenharmony_ci+ * Unless required by applicable law or agreed to in writing, software
172be168c0dSopenharmony_ci+ * distributed under the License is distributed on an "AS IS" BASIS,
173be168c0dSopenharmony_ci+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
174be168c0dSopenharmony_ci+ * See the License for the specific language governing permissions and
175be168c0dSopenharmony_ci+ * limitations under the License.
176be168c0dSopenharmony_ci+ */
177be168c0dSopenharmony_ci+
178be168c0dSopenharmony_ci+#include "src/litert/kernel/cpu/int8/swish_int8.h"
179be168c0dSopenharmony_ci+#include <limits>
180be168c0dSopenharmony_ci+#include <algorithm>
181be168c0dSopenharmony_ci+#include "nnacl/int8/quantize.h"
182be168c0dSopenharmony_ci+#include "src/litert/kernel_registry.h"
183be168c0dSopenharmony_ci+#include "include/errorcode.h"
184be168c0dSopenharmony_ci+
185be168c0dSopenharmony_ci+using mindspore::kernel::KERNEL_ARCH;
186be168c0dSopenharmony_ci+using mindspore::lite::KernelRegistrar;
187be168c0dSopenharmony_ci+using mindspore::lite::RET_ERROR;
188be168c0dSopenharmony_ci+using mindspore::lite::RET_OK;
189be168c0dSopenharmony_ci+using mindspore::schema::ActivationType_SIGMOID;
190be168c0dSopenharmony_ci+
191be168c0dSopenharmony_ci+namespace mindspore::kernel {
192be168c0dSopenharmony_ci+//  Calculate the quantization results of 0-255 in advance
193be168c0dSopenharmony_ci+void CalculateSwishTableList(int8_t *table, const float input_scale, const int32_t input_zp, const float output_scale,
194be168c0dSopenharmony_ci+                             const int32_t output_zp) {
195be168c0dSopenharmony_ci+  int32_t min_value = std::numeric_limits<int8_t>::min();
196be168c0dSopenharmony_ci+  int32_t max_value = std::numeric_limits<int8_t>::max();
197be168c0dSopenharmony_ci+  for (int i = min_value; i < max_value; ++i) {
198be168c0dSopenharmony_ci+    const float real_input_value = input_scale * (i - input_zp);
199be168c0dSopenharmony_ci+    const float sigmoid_value = 1.0f / (1.0f + std::exp(-real_input_value));
200be168c0dSopenharmony_ci+    const int32_t quantized = (std::round(real_input_value * sigmoid_value / output_scale) + output_zp);
201be168c0dSopenharmony_ci+    int8_t out_value = static_cast<int8_t>(std::max(std::min(quantized, max_value), min_value));
202be168c0dSopenharmony_ci+    uint8_t index = static_cast<uint8_t>(i);
203be168c0dSopenharmony_ci+    table[index] = out_value;
204be168c0dSopenharmony_ci+  }
205be168c0dSopenharmony_ci+}
206be168c0dSopenharmony_ci+
207be168c0dSopenharmony_ci+int SwishInt8CPUKernel::Prepare() {
208be168c0dSopenharmony_ci+  CHECK_LESS_RETURN(in_tensors_.size(), C1NUM);
209be168c0dSopenharmony_ci+  CHECK_LESS_RETURN(out_tensors_.size(), C1NUM);
210be168c0dSopenharmony_ci+  CHECK_NULL_RETURN(in_tensors_[0]);
211be168c0dSopenharmony_ci+  CHECK_NULL_RETURN(out_tensors_[0]);
212be168c0dSopenharmony_ci+  if (in_tensors_[0]->data_type() != mindspore::kNumberTypeInt8 ||
213be168c0dSopenharmony_ci+      out_tensors_[0]->data_type() != mindspore::kNumberTypeInt8) {
214be168c0dSopenharmony_ci+    MS_LOG(ERROR) << "Datatype error, input0 data_type is " << in_tensors_[0]->data_type() << ", output data_type is "
215be168c0dSopenharmony_ci+                  << out_tensors_[0]->data_type();
216be168c0dSopenharmony_ci+    return RET_ERROR;
217be168c0dSopenharmony_ci+  }
218be168c0dSopenharmony_ci+  lite::Tensor *input = in_tensors_.at(0);
219be168c0dSopenharmony_ci+  lite::Tensor *output = out_tensors_.at(0);
220be168c0dSopenharmony_ci+  MS_CHECK_TRUE_RET(!input->quant_params().empty() && !output->quant_params().empty(), RET_ERROR);
221be168c0dSopenharmony_ci+  const float input_scale = input->quant_params().front().scale;
222be168c0dSopenharmony_ci+  const int32_t input_zp = input->quant_params().front().zeroPoint;
223be168c0dSopenharmony_ci+  const float output_scale = output->quant_params().front().scale;
224be168c0dSopenharmony_ci+  const int32_t output_zp = output->quant_params().front().zeroPoint;
225be168c0dSopenharmony_ci+  CalculateSwishTableList(table_list_, input_scale, input_zp, output_scale, output_zp);
226be168c0dSopenharmony_ci+  return RET_OK;
227be168c0dSopenharmony_ci+}
228be168c0dSopenharmony_ci+}  // namespace mindspore::kernel
229be168c0dSopenharmony_cidiff --git a/mindspore/lite/src/litert/kernel/cpu/int8/swish_int8.h b/mindspore/lite/src/litert/kernel/cpu/int8/swish_int8.h
230be168c0dSopenharmony_cinew file mode 100644
231be168c0dSopenharmony_ciindex 00000000..7b8ef9ca
232be168c0dSopenharmony_ci--- /dev/null
233be168c0dSopenharmony_ci+++ b/mindspore/lite/src/litert/kernel/cpu/int8/swish_int8.h
234be168c0dSopenharmony_ci@@ -0,0 +1,38 @@
235be168c0dSopenharmony_ci+/**
236be168c0dSopenharmony_ci+ * Copyright 2024 Huawei Technologies Co., Ltd
237be168c0dSopenharmony_ci+ *
238be168c0dSopenharmony_ci+ * Licensed under the Apache License, Version 2.0 (the "License");
239be168c0dSopenharmony_ci+ * you may not use this file except in compliance with the License.
240be168c0dSopenharmony_ci+ * You may obtain a copy of the License at
241be168c0dSopenharmony_ci+ *
242be168c0dSopenharmony_ci+ * http://www.apache.org/licenses/LICENSE-2.0
243be168c0dSopenharmony_ci+ *
244be168c0dSopenharmony_ci+ * Unless required by applicable law or agreed to in writing, software
245be168c0dSopenharmony_ci+ * distributed under the License is distributed on an "AS IS" BASIS,
246be168c0dSopenharmony_ci+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
247be168c0dSopenharmony_ci+ * See the License for the specific language governing permissions and
248be168c0dSopenharmony_ci+ * limitations under the License.
249be168c0dSopenharmony_ci+ */
250be168c0dSopenharmony_ci+
251be168c0dSopenharmony_ci+#ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_CPU_INT8_SWISH_INT8_H_
252be168c0dSopenharmony_ci+#define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_CPU_INT8_SWISH_INT8_H_
253be168c0dSopenharmony_ci+
254be168c0dSopenharmony_ci+#include <vector>
255be168c0dSopenharmony_ci+#include "src/litert/lite_kernel.h"
256be168c0dSopenharmony_ci+#include "src/litert/kernel/cpu/int8/sigmoid_int8.h"
257be168c0dSopenharmony_ci+#include "nnacl/int8/softmax_int8.h"
258be168c0dSopenharmony_ci+#include "nnacl/int8/quantize.h"
259be168c0dSopenharmony_ci+
260be168c0dSopenharmony_ci+namespace mindspore::kernel {
261be168c0dSopenharmony_ci+class SwishInt8CPUKernel : public SigmoidInt8CPUKernel {
262be168c0dSopenharmony_ci+ public:
263be168c0dSopenharmony_ci+  SwishInt8CPUKernel(OpParameter *parameter, const std::vector<lite::Tensor *> &inputs,
264be168c0dSopenharmony_ci+                     const std::vector<lite::Tensor *> &outputs, const lite::InnerContext *ctx)
265be168c0dSopenharmony_ci+      : SigmoidInt8CPUKernel(parameter, inputs, outputs, ctx) {}
266be168c0dSopenharmony_ci+  ~SwishInt8CPUKernel() override = default;
267be168c0dSopenharmony_ci+
268be168c0dSopenharmony_ci+  int Prepare() override;
269be168c0dSopenharmony_ci+};
270be168c0dSopenharmony_ci+}  // namespace mindspore::kernel
271be168c0dSopenharmony_ci+
272be168c0dSopenharmony_ci+#endif  // MINDSPORE_LITE_SRC_RUNTIME_KERNEL_CPU_INT8_SWISH_INT8_H_
273be168c0dSopenharmony_cidiff --git a/mindspore/lite/src/litert/scheduler.cc b/mindspore/lite/src/litert/scheduler.cc
274be168c0dSopenharmony_ciindex 199b4361..96efd972 100644
275be168c0dSopenharmony_ci--- a/mindspore/lite/src/litert/scheduler.cc
276be168c0dSopenharmony_ci+++ b/mindspore/lite/src/litert/scheduler.cc
277be168c0dSopenharmony_ci@@ -511,8 +511,8 @@ int Scheduler::ReplaceDelegateKernels(std::vector<kernel::KernelExec *> *dst_ker
278be168c0dSopenharmony_ci   if (context_->IsDeviceTypeEnabled(DT_NNRT)) {
279be168c0dSopenharmony_ci     auto delegate = static_cast<NNRTDelegate *>(delegate_.get());
280be168c0dSopenharmony_ci     delegate->ShallowCopyLiteGraph(this->src_model_->graph_);
281be168c0dSopenharmony_ci-    void *meta_graph = reinterpret_cast<void*>(const_cast<mindspore::schema::MetaGraph *>(
282be168c0dSopenharmony_ci-      mindspore::schema::GetMetaGraph(this->src_model_->buf)));
283be168c0dSopenharmony_ci+    void *meta_graph = reinterpret_cast<void *>(
284be168c0dSopenharmony_ci+      const_cast<mindspore::schema::MetaGraph *>(mindspore::schema::GetMetaGraph(this->src_model_->buf)));
285be168c0dSopenharmony_ci     delegate->SetMetaGraph(meta_graph);
286be168c0dSopenharmony_ci   }
287be168c0dSopenharmony_ci #endif
288be168c0dSopenharmony_ci@@ -865,7 +865,9 @@ int Scheduler::InferSubGraphShape(size_t subgraph_index) {
289be168c0dSopenharmony_ci   infer_subgraph_index_.push_back(subgraph_index);
290be168c0dSopenharmony_ci   auto subgraph = src_model_->graph_.sub_graphs_.at(subgraph_index);
291be168c0dSopenharmony_ci   int subgraph_infershape_ret = RET_OK;
292be168c0dSopenharmony_ci-  for (auto node_index : subgraph->node_indices_) {
293be168c0dSopenharmony_ci+  auto node_indexes = subgraph->node_indices_;
294be168c0dSopenharmony_ci+  for (size_t i = 0; i < node_indexes.size(); ++i) {
295be168c0dSopenharmony_ci+    auto node_index = node_indexes[i];
296be168c0dSopenharmony_ci     auto node = src_model_->graph_.all_nodes_[node_index];
297be168c0dSopenharmony_ci     MS_ASSERT(node != nullptr);
298be168c0dSopenharmony_ci     auto *primitive = node->primitive_;
299be168c0dSopenharmony_ci@@ -877,6 +879,7 @@ int Scheduler::InferSubGraphShape(size_t subgraph_index) {
300be168c0dSopenharmony_ci       // convert shape to built-in shape
301be168c0dSopenharmony_ci       MS_CHECK_TRUE_RET(node->input_indices_.size() == 1, RET_ERROR);
302be168c0dSopenharmony_ci       shape_fusion_pass_->Run(node, subgraph_index);
303be168c0dSopenharmony_ci+      node_indexes = subgraph->node_indices_;
304be168c0dSopenharmony_ci     }
305be168c0dSopenharmony_ci     auto ret = InferNodeShape(node);
306be168c0dSopenharmony_ci     if (ret == RET_INFER_INVALID) {
307be168c0dSopenharmony_ci-- 
308be168c0dSopenharmony_ci2.31.1
309be168c0dSopenharmony_ci
310