temp fixed huge lr groups returned from C

This commit is contained in:
sugarme 2021-07-08 15:38:00 +10:00
parent b536d800d2
commit 77031295cb
2 changed files with 8 additions and 0 deletions

View File

@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
- Fixed temporary fix huge number of learning group returned from C at `libtch/tensor.go AtoGetLearningRates`
## [Nofix]
- ctype `long` caused compiling error in MacOS as noted on [#44]. Not working on linux box.

View File

@ -464,6 +464,12 @@ func AtoGetLearningRates(coptimizer Coptimizer) []float64 {
C.ato_get_learning_rates(coptimizer, cLRsPtr, cngroup)
ngroup := *(*int)(unsafe.Pointer(cngroup))
// NOTE. temp fix `panic: runtime error: makeslice: len out of range`
// due to error in C side with ngroup ridiculous huge number (ie. ngroup: 139745350909953)
if ngroup > 1000 {
ngroup = 1
}
var lrs []float64 = make([]float64, ngroup)
var currPtr *C.double = cLRsPtr
for i := 0; i < ngroup; i++ {