https://github.com/changkun/libtorch-go
libtorch Go wrapper for model inference
https://github.com/changkun/libtorch-go
Last synced: 11 months ago
JSON representation
libtorch Go wrapper for model inference
- Host: GitHub
- URL: https://github.com/changkun/libtorch-go
- Owner: changkun
- License: bsd-3-clause
- Created: 2024-07-28T12:10:53.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-13T18:27:54.000Z (over 1 year ago)
- Last Synced: 2025-02-22T05:42:17.765Z (11 months ago)
- Language: Go
- Homepage:
- Size: 68.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# libtorch-go
libtorch Go wrapper for model inference
## Dependencies
- [libtorch](https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.4.0.zip)
## Usage
```go
package main
import (
"fmt"
"changkun.de/x/libtorch-go"
)
func main() {
m := libtorch.NewModel("model.pt")
defer m.Close()
nsamples, nfeatures := 2, 4
x := []float32{1, 2, 3, 4, 1, 2, 3, 4}
// Output: [13.449158 13.449158]
fmt.Println(m.Predict(x, nsamples, nfeatures))
}
```
For more details, see [example](./example) folder.