Fix return type of TypeFactoryBase<c10::DynamicType>::get (#151803)

getBaseType() actually returns a reference. This was causing shared_ptr copies.

Differential Revision: [D73376717](https://our.internmc.facebook.com/intern/diff/D73376717/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151803
Approved by: https://github.com/malfet, https://github.com/Skylion007
ghstack dependencies: #151801, #151802
This commit is contained in:
Scott Wolchok 2025-04-23 17:22:22 -07:00 committed by PyTorch MergeBot
parent fabbcddab1
commit 0559741d7f

View File

@ -44,7 +44,7 @@ struct TORCH_API TypeFactoryBase<c10::DynamicType> {
c10::DynamicType::Arguments{});
}
template <typename T>
C10_ERASE static c10::DynamicTypePtr get() {
C10_ERASE static decltype(auto) get() {
return DynamicTypeTrait<T>::getBaseType();
}
static const std::unordered_map<std::string, c10::TypePtr>& basePythonTypes();