Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FlattenSlice ¶
Flatten a slice of the given kind to a 1-dimensional buffer of contiguous data. The input is expected to be an n-dimensional slice of data and the output is the `Data` buffer of the flattened representation of the input.
https://medium.com/@the1mills/flattening-arrays-slices-with-golang-c796905debbe provides a way to flatten any recursive slices into []interface{}. However, we cannot reuse this solution here, because libtorch wants []float32/float64/..., instead of []interface{}. Without type template as that in C++, we have to write the following Go switch over types.
func GetSizesAndKindOfSlice ¶
Extract the shape and data-type of a slice. Returns a tuple of the shape of the tensor-like data structure, and the kind of the elements contained by the tensor-like structure.
func MockCException ¶
Create a mock C error with a message. We intentionally do not defer the freeing of the C-string to mock the functionality of the C interface that will transfer ownership of non-nil pointer returns to the caller.
func NewTorchError ¶
@brief Create a new error from a verified char*. @param err The char* that is guaranteed to not be nil. @returns The formatted error structure. @details The input `err` is expected to be a valid char* that is managed by the Golang context. When the string is copied, it will be freed using Cgo.
func PanicOnCException ¶
Panic if a system error is caught in the error buffer. @param error A *C.Char to an error string that may be nil.
Types ¶
This section is empty.