Fix build error
This commit is contained in:
parent
8031bb85f5
commit
6f7d68572b
12
ts/scalar.go
12
ts/scalar.go
|
@ -20,6 +20,8 @@ func freeCScalar(x *Scalar) error {
|
||||||
if gotch.Debug {
|
if gotch.Debug {
|
||||||
nbytes := x.nbytes()
|
nbytes := x.nbytes()
|
||||||
atomic.AddInt64(&AllocatedMem, -nbytes)
|
atomic.AddInt64(&AllocatedMem, -nbytes)
|
||||||
|
|
||||||
|
log.Printf("INFO: Released scalar %q - C memory: %d bytes.\n", x.name, nbytes)
|
||||||
}
|
}
|
||||||
lock.Lock()
|
lock.Lock()
|
||||||
delete(ExistingScalars, x.name)
|
delete(ExistingScalars, x.name)
|
||||||
|
@ -30,10 +32,6 @@ func freeCScalar(x *Scalar) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if gotch.Debug {
|
|
||||||
log.Printf("INFO: Released scalar %q - C memory: %d bytes.\n", x.name, nbytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,15 +56,13 @@ func newScalar(cscalar lib.Cscalar, nameOpt ...string) *Scalar {
|
||||||
if gotch.Debug {
|
if gotch.Debug {
|
||||||
nbytes := x.nbytes()
|
nbytes := x.nbytes()
|
||||||
atomic.AddInt64(&AllocatedMem, nbytes)
|
atomic.AddInt64(&AllocatedMem, nbytes)
|
||||||
|
|
||||||
|
log.Printf("INFO: scalar %q added - Allocated memory (%d bytes).\n", x.name, nbytes)
|
||||||
}
|
}
|
||||||
lock.Lock()
|
lock.Lock()
|
||||||
ExistingScalars[x.name] = struct{}{}
|
ExistingScalars[x.name] = struct{}{}
|
||||||
lock.Unlock()
|
lock.Unlock()
|
||||||
|
|
||||||
if gotch.Debug {
|
|
||||||
log.Printf("INFO: scalar %q added - Allocated memory (%d bytes).\n", x.name, nbytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.SetFinalizer(x, freeCScalar)
|
runtime.SetFinalizer(x, freeCScalar)
|
||||||
|
|
||||||
return x
|
return x
|
||||||
|
|
|
@ -70,6 +70,8 @@ func newTensor(ctensor lib.Ctensor, nameOpt ...string) *Tensor {
|
||||||
if gotch.Debug {
|
if gotch.Debug {
|
||||||
nbytes := x.nbytes()
|
nbytes := x.nbytes()
|
||||||
atomic.AddInt64(&AllocatedMem, nbytes)
|
atomic.AddInt64(&AllocatedMem, nbytes)
|
||||||
|
|
||||||
|
log.Printf("INFO: Added tensor %q - Allocated memory: %d bytes.\n", x.name, nbytes)
|
||||||
}
|
}
|
||||||
lock.Lock()
|
lock.Lock()
|
||||||
if _, ok := ExistingTensors[name]; ok {
|
if _, ok := ExistingTensors[name]; ok {
|
||||||
|
@ -80,10 +82,6 @@ func newTensor(ctensor lib.Ctensor, nameOpt ...string) *Tensor {
|
||||||
|
|
||||||
x.name = name
|
x.name = name
|
||||||
|
|
||||||
if gotch.Debug {
|
|
||||||
log.Printf("INFO: Added tensor %q - Allocated memory: %d bytes.\n", x.name, nbytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
x.calledFrom = "newTensor()"
|
x.calledFrom = "newTensor()"
|
||||||
|
|
||||||
runtime.SetFinalizer(x, freeCTensor)
|
runtime.SetFinalizer(x, freeCTensor)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user