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()`
|
- reworked `ts.Format()`
|
||||||
- Added conv2d benchmark
|
- Added conv2d benchmark
|
||||||
- Fixed #88 memory leak at `example/char-rnn`
|
- Fixed #88 memory leak at `example/char-rnn`
|
||||||
|
- Added missing tensor `Stride()`
|
||||||
|
|
||||||
## [Nofix]
|
## [Nofix]
|
||||||
- ctype `long` caused compiling error in MacOS as noted on [#44]. Not working on linux box.
|
- 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)
|
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);
|
// int at_scalar_type(tensor);
|
||||||
func AtScalarType(t Ctensor) int32 {
|
func AtScalarType(t Ctensor) int32 {
|
||||||
result := C.at_scalar_type(t)
|
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.
|
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)
|
// Tensor is a Go wrapper of a "C tensor pointer" - 8 Bytes (64-bits OS)
|
||||||
// ctensor is just a C pointer to `torch::Tensor`
|
// 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.
|
// NOTE.Tensor should be big enough to be in heap memory.
|
||||||
// See. https://stackoverflow.com/questions/10866195
|
// (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 {
|
type Tensor struct {
|
||||||
d *bigStruct
|
d *bigStruct
|
||||||
name string
|
name string
|
||||||
|
|
Loading…
Reference in New Issue
Block a user