From 9bc9d22409b2569e825f3c4aba01bbbdb08e9a80 Mon Sep 17 00:00:00 2001 From: sugarme Date: Thu, 10 Dec 2020 09:21:03 +1100 Subject: [PATCH] fixed(nn/varstore): fixed nil pointer at LoadPartial due to not break loop --- nn/varstore.go | 1 + tensor/util.go | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nn/varstore.go b/nn/varstore.go index dd47c6f..d09d050 100644 --- a/nn/varstore.go +++ b/nn/varstore.go @@ -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 diff --git a/tensor/util.go b/tensor/util.go index f4e9d01..e5814da 100644 --- a/tensor/util.go +++ b/tensor/util.go @@ -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