From ddf1537cf6708fb14bf61c0178a6480368b1df1a Mon Sep 17 00:00:00 2001 From: Fu Jingguo Date: Wed, 29 Sep 2021 10:33:30 +0800 Subject: [PATCH] fix bug for add subgraph of onnx models failed --- .../depends/ge_runner/src/ascend_string.cc | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 tf_adapter/tests/depends/ge_runner/src/ascend_string.cc diff --git a/tf_adapter/tests/depends/ge_runner/src/ascend_string.cc b/tf_adapter/tests/depends/ge_runner/src/ascend_string.cc new file mode 100644 index 000000000..e0a4bf50c --- /dev/null +++ b/tf_adapter/tests/depends/ge_runner/src/ascend_string.cc @@ -0,0 +1,98 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "external/graph/ascend_string.h" + +namespace ge { +AscendString::AscendString(const char* name) { + if (name != nullptr) { + name_ = std::shared_ptr(new (std::nothrow) std::string(name)); //lint !e1524 + if (name_ == nullptr) { + fprintf(stderr, "[New][String]AscendString[%s] make shared failed.", name); + } + } +} + +const char* AscendString::GetString() const { + if (name_ == nullptr) { + return nullptr; + } + + return (*name_).c_str(); +} + +bool AscendString::operator<(const AscendString& d) const { + if (name_ == nullptr && d.name_ == nullptr) { + return false; + } else if (name_ == nullptr) { + return true; + } else if (d.name_ == nullptr) { + return false; + } + return (*name_ < *(d.name_)); +} + +bool AscendString::operator>(const AscendString& d) const { + if (name_ == nullptr && d.name_ == nullptr) { + return false; + } else if (name_ == nullptr) { + return false; + } else if (d.name_ == nullptr) { + return true; + } + return(*name_ > *(d.name_)); +} + +bool AscendString::operator==(const AscendString& d) const { + if (name_ == nullptr && d.name_ == nullptr) { + return true; + } else if (name_ == nullptr) { + return false; + } else if (d.name_ == nullptr) { + return false; + } + return (*name_ == *(d.name_)); +} + +bool AscendString::operator<=(const AscendString& d) const { + if (name_ == nullptr) { + return true; + } else if (d.name_ == nullptr) { + return false; + } + return (*name_ <= *(d.name_)); +} + +bool AscendString::operator>=(const AscendString& d) const { + if (d.name_ == nullptr) { + return true; + } else if (name_ == nullptr) { + return false; + } + return (*name_ >= *(d.name_)); +} + +bool AscendString::operator!=(const AscendString& d) const { + if (name_ == nullptr && d.name_ == nullptr) { + return false; + } else if (name_ == nullptr) { + return true; + } else if (d.name_ == nullptr) { + return true; + } + return (*name_ != *(d.name_)); +} +} // namespace ge -- Gitee