From d229e53266cb24ab2fa948ef3eff9aad6af62059 Mon Sep 17 00:00:00 2001 From: liangzelang Date: Mon, 5 Jul 2021 16:34:16 +0800 Subject: [PATCH] Add AbstractTuple comparision. --- .../backend/session/ascend_auto_monad.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mindspore/ccsrc/backend/session/ascend_auto_monad.cc b/mindspore/ccsrc/backend/session/ascend_auto_monad.cc index 06c366ad82c..0386a47f960 100644 --- a/mindspore/ccsrc/backend/session/ascend_auto_monad.cc +++ b/mindspore/ccsrc/backend/session/ascend_auto_monad.cc @@ -151,6 +151,25 @@ bool IsCompatible(const abstract::AbstractBasePtr &a1, const abstract::AbstractB if (a1 == a2) { return true; } + // Check AbstractTuple. + if (a1->isa() && a2->isa()) { + auto &a1_tuple = static_cast(*a1); + auto &a2_tuple = static_cast(*a2); + auto &a1_elements = a1_tuple.elements(); + auto &a2_elements = a2_tuple.elements(); + if (a1_elements.size() != a2_elements.size()) { + return false; + } + for (size_t i = 0; i < a1_elements.size(); i++) { + MS_EXCEPTION_IF_NULL(a1_elements[i]); + MS_EXCEPTION_IF_NULL(a2_elements[i]); + if (!IsCompatible(a1_elements[i], a2_elements[i])) { + return false; + } + } + return true; + } + // Check AbstractTensor and AbstractRef. auto type1 = a1->BuildType(); auto type2 = a2->BuildType(); if (type1 != type2 && *type1 != *type2) {