fixed(nn/varstore): fixed nil pointer at LoadPartial due to not break loop
This commit is contained in:
parent
8770fc378b
commit
9bc9d22409
|
@ -228,6 +228,7 @@ func (vs *VarStore) LoadPartial(filepath string) ([]string, error) {
|
||||||
// missing variable
|
// missing variable
|
||||||
if currTs, ok = namedTensorsMap[tsName]; !ok {
|
if currTs, ok = namedTensorsMap[tsName]; !ok {
|
||||||
missingVariables = append(missingVariables, tsName)
|
missingVariables = append(missingVariables, tsName)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// mismatched shape
|
// mismatched shape
|
||||||
|
|
|
@ -56,9 +56,8 @@ func CMalloc(nbytes int) (dataPtr unsafe.Pointer, buf *bytes.Buffer) {
|
||||||
// NOTE: uncomment this cause panic!
|
// NOTE: uncomment this cause panic!
|
||||||
// defer C.free(unsafe.Pointer(dataPtr))
|
// defer C.free(unsafe.Pointer(dataPtr))
|
||||||
|
|
||||||
// Recall: 1 << 30 = 1 * 2 * 30
|
// Recall: 1 << 30 = 1 * 2 * 30 = 1073741824
|
||||||
// Ref. See more at https://stackoverflow.com/questions/48756732
|
dataSlice := (*[1 << 32]byte)(dataPtr)[:nbytes:nbytes] // 4294967296
|
||||||
dataSlice := (*[1 << 30]byte)(dataPtr)[:nbytes:nbytes]
|
|
||||||
buf = bytes.NewBuffer(dataSlice[:0:nbytes])
|
buf = bytes.NewBuffer(dataSlice[:0:nbytes])
|
||||||
|
|
||||||
return dataPtr, buf
|
return dataPtr, buf
|
||||||
|
|
Loading…
Reference in New Issue
Block a user