Compare commits

...

1 Commits

Author SHA1 Message Date
138dcbd902 [Codemod][Modernize Containers] fbcode//caffe2:torch_sources [A]
Reviewed By: dtolnay

Differential Revision: D78934925
2025-07-24 16:30:24 -07:00
4 changed files with 6 additions and 6 deletions

View File

@ -14,12 +14,12 @@ void ThreadLocalPythonObjects::set(const std::string& key, std::shared_ptr<SafeP
}
const std::shared_ptr<SafePyObject>& ThreadLocalPythonObjects::get(const std::string& key) {
TORCH_CHECK(py_objects.obj_dict_.count(key));
TORCH_CHECK(py_objects.obj_dict_.contains(key));
return py_objects.obj_dict_[key];
}
bool ThreadLocalPythonObjects::contains(const std::string& key) {
return py_objects.obj_dict_.count(key);
return py_objects.obj_dict_.contains(key);
}
void ThreadLocalPythonObjects::set_state(ThreadLocalPythonObjects state) {

View File

@ -71,7 +71,7 @@ void registerCustomClass(at::ClassTypePtr class_type) {
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
auto name = class_type->name()->qualifiedName();
TORCH_CHECK(
!customClasses().count(name),
!customClasses().contains(name),
"Custom class with name ",
name,
" is already registered. Ensure that registration with torch::class_ is only called once.");
@ -80,7 +80,7 @@ void registerCustomClass(at::ClassTypePtr class_type) {
at::ClassTypePtr getCustomClass(const std::string& class_name) {
auto ret =
customClasses().count(class_name) ? customClasses()[class_name] : nullptr;
customClasses().contains(class_name) ? customClasses()[class_name] : nullptr;
if (ret) {
RECORD_CUSTOM_CLASS(class_name);
}

View File

@ -23,7 +23,7 @@ std::unordered_set<std::string>& ObservedOperators::getUnobservedOperatorList()
/* static */
bool ObservedOperators::isObserved(const OperatorName& name) {
return !ObservedOperators::getUnobservedOperatorList().count(name.name);
return !ObservedOperators::getUnobservedOperatorList().contains(name.name);
}
} // namespace c10

View File

@ -90,7 +90,7 @@ std::optional<AliasTypeSet> FunctionSchema::getAliasTypeSetContainedTypes(const
while (!typeStack.empty()) {
TypePtr current = typeStack.top();
typeStack.pop();
if (!containedTypes.count(current)) {
if (!containedTypes.contains(current)) {
for (const TypePtr& containedType : current->containedTypes()) {
typeStack.push(containedType);
}