fixed pickle with zero data length

This commit is contained in:
sugarme 2022-02-27 11:50:26 +11:00
parent 8eab6a5bbd
commit e43f22df69
2 changed files with 7 additions and 0 deletions

View File

@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
- Fixed pickle with zero data length
- Added `gotch.CleanCache()` API.
## [Nofix]

View File

@ -13,6 +13,7 @@ import (
"errors"
"fmt"
"io"
"log"
"math/big"
"os"
"path"
@ -75,6 +76,11 @@ func Decode(filename string) (map[string]*ts.Tensor, error) {
// log.Printf("data: %v\n", data)
// Dealing with Pytorch `..._tracked` variables.
if reflect.ValueOf(data).Len() == 0 {
log.Printf("INFO: skip weigth %q with zero data length.\n", name.(string))
continue
}
// TODO. should we just skip them?
if reflect.ValueOf(data).Len() == 1 && len(size) == 0 {
size = []int64{1}