clean-up
This commit is contained in:
parent
d1b9267c77
commit
66599380d4
|
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- reworked `ts.Format()`
|
||||
- Added conv2d benchmark
|
||||
- Fixed #88 memory leak at `example/char-rnn`
|
||||
- Added missing tensor `Stride()`
|
||||
|
||||
## [Nofix]
|
||||
- ctype `long` caused compiling error in MacOS as noted on [#44]. Not working on linux box.
|
||||
|
|
|
@ -100,6 +100,12 @@ func AtShape(t Ctensor, ptr unsafe.Pointer) {
|
|||
C.at_shape(t, c_ptr)
|
||||
}
|
||||
|
||||
// void at_stride(tensor, int64_t *);
|
||||
func AtStride(t Ctensor, ptr unsafe.Pointer) {
|
||||
c_ptr := (*C.int64_t)(ptr)
|
||||
C.at_stride(t, c_ptr)
|
||||
}
|
||||
|
||||
// int at_scalar_type(tensor);
|
||||
func AtScalarType(t Ctensor) int32 {
|
||||
result := C.at_scalar_type(t)
|
||||
|
|
12
ts/tensor.go
12
ts/tensor.go
|
@ -40,11 +40,15 @@ type bigStruct struct {
|
|||
lots [1e5]byte // 100k - always on host memory.
|
||||
}
|
||||
|
||||
// Tensor is a Go wrapper to a C tensor pointer - 8 Bytes (64-bits OS) or 4 Bytes (32-bits OS)
|
||||
// ctensor is just a C pointer to `torch::Tensor`
|
||||
// Tensor is a Go wrapper of a "C tensor pointer" - 8 Bytes (64-bits OS)
|
||||
// or 4 Bytes (32-bits OS).
|
||||
// `ctensor` is just a "C pointer" to `torch::Tensor` (torch::Tensor *lib.Ctensor)
|
||||
//
|
||||
// NOTE.Tensor should be big enough to be in a heap.
|
||||
// See. https://stackoverflow.com/questions/10866195
|
||||
// NOTE.Tensor should be big enough to be in heap memory.
|
||||
// (yes, we choose to place tensor consistently in heap memory so that
|
||||
// it can be targeted by Go garbage collector).
|
||||
//
|
||||
// For heap allocation see. https://stackoverflow.com/questions/10866195
|
||||
type Tensor struct {
|
||||
d *bigStruct
|
||||
name string
|
||||
|
|
Loading…
Reference in New Issue
Block a user