已合并
fix: 区分自定义算子路径stat失败处理 #4144
duhua创建于 24 天前
fix: 区分自定义算子路径stat失败处理 #4144
已合并
duhua创建于 24 天前
2 个文件变更+8-4
Mruntime/custom_op/python_custom_op_bridge_loader.cc+6-2
@@ -111,8 +111,12 @@ Status FindPythonCustomOpEntryInEnv(const char *env_value, bool &found) {
111 }111 }
112 struct stat path_stat{};112 struct stat path_stat{};
113 if (stat(path.c_str(), &path_stat) != 0) {113 if (stat(path.c_str(), &path_stat) != 0) {
114- GELOGE(FAILED, "Custom op path[%s] does not exist or is inaccessible.", path.c_str());114+ if (IsPythonFile(path)) {
115- return FAILED;115+ GELOGE(FAILED, "Python custom op path[%s] does not exist or is inaccessible.", path.c_str());
116+ return FAILED;
117+ }
118+ GELOGW("Skip inaccessible custom op path[%s].", path.c_str());
119+ continue;
116 }120 }
117 if (HasPythonCustomOpEntry(path, path_stat)) {121 if (HasPythonCustomOpEntry(path, path_stat)) {
118 found = true;122 found = true;
Mtests/ge/st/testcase/test_custom_op.cc+2-2
@@ -1589,13 +1589,13 @@ TEST_F(CustomOpFactoryStTest, load_python_custom_ops_if_needed_fails_for_missing
1589 EXPECT_EQ(custom_op::LoadPythonCustomOpsIfNeeded(), FAILED);1589 EXPECT_EQ(custom_op::LoadPythonCustomOpsIfNeeded(), FAILED);
1590}1590}
1591 1591 
1592-TEST_F(CustomOpFactoryStTest, check_need_load_python_custom_ops_fails_for_missing_non_python_path) {1592+TEST_F(CustomOpFactoryStTest, check_need_load_python_custom_ops_skips_missing_non_python_path) {
1593 ScopedTempDirForCustomOpSt temp_dir;1593 ScopedTempDirForCustomOpSt temp_dir;
1594 const auto missing_so_file = temp_dir.FilePath("missing_custom_op.so");1594 const auto missing_so_file = temp_dir.FilePath("missing_custom_op.so");
1595 ScopedEnvVarForCustomOpSt scoped_custom_opp_path(kEnvPythonCustomOpPath, missing_so_file);1595 ScopedEnvVarForCustomOpSt scoped_custom_opp_path(kEnvPythonCustomOpPath, missing_so_file);
1596 1596 
1597 bool need_load = true;1597 bool need_load = true;
1598- EXPECT_EQ(custom_op::CheckNeedLoadPythonCustomOps(need_load), FAILED);1598+ EXPECT_EQ(custom_op::CheckNeedLoadPythonCustomOps(need_load), SUCCESS);
1599 EXPECT_FALSE(need_load);1599 EXPECT_FALSE(need_load);
1600}1600}
1601 1601