diff --git a/test/npu/test_cann_version.py b/test/npu/test_cann_version.py index 76925b9b4439903dc410e3107d1b889116eca731..3663bc7868327a17b50d122cf3bca29428bdd376 100644 --- a/test/npu/test_cann_version.py +++ b/test/npu/test_cann_version.py @@ -17,12 +17,23 @@ class TestCANNversion(TestCase): or re.match("([0-9]+).([0-9]+).T([0-9]+)", version) or re.match("([0-9]+).([0-9]+).RC([0-9]+).alpha([0-9]+)", version)) self.assertTrue(is_match, f"The env version is {version_env}. The format of cann version {version} is invalid.") + + version = get_cann_version(module="CAN") + self.assertTrue(version == "", "When module is invalid, the result of get_cann_version is not right.") def test_compare_cann_version(self): version_env = get_cann_version_from_env() if not version_env.startswith("CANN") and version_env >= "8.1.RC1": result = _is_gte_cann_version("8.1.RC1", module="CANN") self.assertTrue(result, f"The env version is {version_env}, the result from _is_gte_cann_version is False") + + tags = get_cann_version(module="CANN") + major = int(tags[0]) + 1 + result1 = _is_gte_cann_version(f"{major}.0.0", module="CANN") + result2 = _is_gte_cann_version(f"{major}.0.T10", module="CANN") + result3 = _is_gte_cann_version(f"{major}.0.RC1.alpha001", module="CANN") + self.assertTrue(not result1 and not result2 and not result3, "the result from _is_gte_cann_version is not right.") + else: with self.assertRaisesRegex(RuntimeError, "When the version 7.0.0 is less than \"8.1.RC1\", this function is not supported"): diff --git a/torch_npu/csrc/core/npu/GetCANNInfo.cpp b/torch_npu/csrc/core/npu/GetCANNInfo.cpp index cc817f5506ae2e654caec02cd1a7bc1923382152..22daec8ea048101dd6b75596532028115cb01298 100644 --- a/torch_npu/csrc/core/npu/GetCANNInfo.cpp +++ b/torch_npu/csrc/core/npu/GetCANNInfo.cpp @@ -138,7 +138,7 @@ std::string GetCANNVersion(const std::string& module) } auto find_module = packageNameMap.find(module); if (find_module == packageNameMap.end()) { - TORCH_NPU_WARN_ONCE("module " + module + "is invalid."); + TORCH_NPU_WARN_ONCE("module " + module + " is invalid."); CANNVersionCache[module] = ""; return ""; }