Support defaultdict in PyTorch checkpoints. (#1696)

* Support defaultdict in PyTorch checkpoints.

* Fix clippy lint.
This commit is contained in:
Laurent Mazare
2024-02-12 10:26:56 +01:00
committed by GitHub
parent 1e26d539d9
commit 274bf11633

View File

@ -350,8 +350,10 @@ impl Stack {
module_name,
class_name,
} => {
if module_name == "collections" && class_name == "OrderedDict" {
// TODO: have a separate ordered dict.
if module_name == "collections"
&& (class_name == "OrderedDict" || class_name == "defaultdict")
{
// TODO: have a separate ordered dict and a separate default dict.
Some(Object::Dict(vec![]))
} else {
None