fixed(nn/varstore): fixed nil pointer at LoadPartial due to not break loop

This commit is contained in:
sugarme 2020-12-10 09:21:03 +11:00
parent 8770fc378b
commit 9bc9d22409
2 changed files with 3 additions and 3 deletions

View File

@ -228,6 +228,7 @@ func (vs *VarStore) LoadPartial(filepath string) ([]string, error) {
// missing variable
if currTs, ok = namedTensorsMap[tsName]; !ok {
missingVariables = append(missingVariables, tsName)
continue
}
// mismatched shape

View File

@ -56,9 +56,8 @@ func CMalloc(nbytes int) (dataPtr unsafe.Pointer, buf *bytes.Buffer) {
// NOTE: uncomment this cause panic!
// defer C.free(unsafe.Pointer(dataPtr))
// Recall: 1 << 30 = 1 * 2 * 30
// Ref. See more at https://stackoverflow.com/questions/48756732
dataSlice := (*[1 << 30]byte)(dataPtr)[:nbytes:nbytes]
// Recall: 1 << 30 = 1 * 2 * 30 = 1073741824
dataSlice := (*[1 << 32]byte)(dataPtr)[:nbytes:nbytes] // 4294967296
buf = bytes.NewBuffer(dataSlice[:0:nbytes])
return dataPtr, buf