• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From b163f226d50d0b43813c0d61929b39dc8529c52d Mon Sep 17 00:00:00 2001
2From: chengfeng27 <chengfeng27@huawei.com>
3Date: Sat, 15 Jun 2024 21:14:45 +0800
4Subject: [PATCH] fix gcn model squeeze/transpose infershape not do
5
6---
7 mindspore/lite/src/litert/executor.cc            | 16 +++++++++++++++-
8 .../src/litert/kernel/cpu/nnacl/nnacl_reshape.cc | 12 ++++++++----
9 2 files changed, 23 insertions(+), 5 deletions(-)
10
11diff --git a/mindspore/lite/src/litert/executor.cc b/mindspore/lite/src/litert/executor.cc
12index b4e9d1d3..cb6d7451 100644
13--- a/mindspore/lite/src/litert/executor.cc
14+++ b/mindspore/lite/src/litert/executor.cc
15@@ -1,5 +1,5 @@
16 /**
17- * Copyright 2020 Huawei Technologies Co., Ltd
18+ * Copyright 2024 Huawei Technologies Co., Ltd
19  *
20  * Licensed under the Apache License, Version 2.0 (the "License");
21  * you may not use this file except in compliance with the License.
22@@ -31,11 +31,25 @@ int Executor::Run(const std::vector<Tensor *> &in_tensors, const std::vector<Ten
23
24   // clear ref_count
25   for (auto *kernel : kernels) {
26+    CHECK_NULL_RETURN(kernel);
27     for (auto *tensor : kernel->in_tensors()) {
28+      CHECK_NULL_RETURN(tensor);
29       tensor->set_ref_count(0);
30     }
31   }
32
33+  // clear output ref_couont
34+  for (auto output_tensor : out_tensors) {
35+    CHECK_NULL_RETURN(output_tensor);
36+    if (output_tensor->allocator() != nullptr) {
37+      output_tensor->DecRefCount();
38+    } else {
39+      /* user set graph->-output-tensor from outside */
40+      output_tensor->set_own_data(false);
41+      output_tensor->set_allocator(nullptr);
42+    }
43+  }
44+
45   for (auto kernel : kernels) {
46     int ret = kernel->Execute(before, after);
47     if (ret != RET_OK) {
48diff --git a/mindspore/lite/src/litert/kernel/cpu/nnacl/nnacl_reshape.cc b/mindspore/lite/src/litert/kernel/cpu/nnacl/nnacl_reshape.cc
49index ef479364..ab7f2796 100644
50--- a/mindspore/lite/src/litert/kernel/cpu/nnacl/nnacl_reshape.cc
51+++ b/mindspore/lite/src/litert/kernel/cpu/nnacl/nnacl_reshape.cc
52@@ -1,5 +1,5 @@
53 /**
54- * Copyright 2023 Huawei Technologies Co., Ltd
55+ * Copyright 2024 Huawei Technologies Co., Ltd
56  *
57  * Licensed under the Apache License, Version 2.0 (the "License");
58  * you may not use this file except in compliance with the License.
59@@ -41,9 +41,13 @@ int ReshapeKernel::Run() {
60     return RET_OK;
61   }
62
63-  if (in_tensor->data_type() != out_tensor->data_type() || in_tensor->data() == nullptr ||
64-      in_tensor->Size() != out_tensor->Size()) {
65-    MS_LOG(ERROR) << "NNACL check reshape parameter failed. Kernel: " << name();
66+  if (in_tensor->data_type() != out_tensor->data_type()) {
67+    MS_LOG(ERROR) << "NNACL check in_tensor and out_tensor dtype failed. Kernel: " << name();
68+    return RET_ERROR;
69+  }
70+
71+  if (in_tensor->data() == nullptr || in_tensor->Size() != out_tensor->Size()) {
72+    MS_LOG(ERROR) << "NNACL check in_tensor and out_tensor size failed, Kernel: " << name();
73     return RET_ERROR;
74   }
75
76--
772.17.1
78
79