MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / IsProbablySafeToLoad

Function IsProbablySafeToLoad

tensorflow/core/framework/op_kernel.cc:1090–1121  ·  view source on GitHub ↗

Returns Status::OK if the dynamic library at the given path is safe to load with some level of confidence.

Source from the content-addressed store, hash-verified

1088// Returns Status::OK if the dynamic library at the given path is safe to
1089// load with some level of confidence.
1090static Status IsProbablySafeToLoad(const string& path) {
1091 // A map of platform string to required CPU feature.
1092 using port::CPUFeature;
1093 static const auto* feature_map =
1094 new std::map<string, std::pair<CPUFeature, string>>{
1095 {"__AVX512VL__=1", FEATURE(CPUFeature::AVX512VL)},
1096 };
1097
1098 std::vector<std::string> platform_strings;
1099 int result = GetPlatformStrings(path, &platform_strings);
1100 if (result) {
1101 return Status(error::Code::UNKNOWN, strerror(result));
1102 }
1103 if (platform_strings.empty()) {
1104 return Status(error::Code::FAILED_PRECONDITION,
1105 "Didn't find any platform strings");
1106 }
1107 std::vector<std::string> missing_features;
1108 for (const auto& platform_string : platform_strings) {
1109 const auto& entry = feature_map->find(platform_string);
1110 if (entry != feature_map->end() &&
1111 !port::TestCPUFeature(entry->second.first)) {
1112 missing_features.emplace_back(entry->second.second);
1113 }
1114 }
1115 if (!missing_features.empty()) {
1116 string errmsg = "Missing CPU features: ";
1117 errmsg.append(absl::StrJoin(missing_features, ", "));
1118 return Status(errors::Code::FAILED_PRECONDITION, errmsg);
1119 }
1120 return Status::OK();
1121}
1122
1123void LoadDynamicKernelsInternal() {
1124 Env* env = Env::Default();

Callers 1

Calls 8

GetPlatformStringsFunction · 0.85
TestCPUFeatureFunction · 0.85
StatusClass · 0.50
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
emplace_backMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected