-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompilation.go
More file actions
89 lines (73 loc) · 2.9 KB
/
compilation.go
File metadata and controls
89 lines (73 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Code generated by idiomgen. DO NOT EDIT.
package nnapi
import (
"unsafe"
capi "github.com/AndroidGoLab/ndk/capi/neuralnetworks"
)
// Compilation wraps the NDK ANeuralNetworksCompilation handle.
type Compilation struct {
ptr *capi.ANeuralNetworksCompilation
}
// cptr returns the underlying C pointer, or nil if h is nil.
// This allows passing optional (nullable) handle parameters to capi functions.
func (h *Compilation) cptr() *capi.ANeuralNetworksCompilation {
if h == nil {
return nil
}
return h.ptr
}
// NewCompilationFromPointer wraps a raw ANeuralNetworksCompilation pointer.
func NewCompilationFromPointer(ptr unsafe.Pointer) *Compilation {
return &Compilation{ptr: (*capi.ANeuralNetworksCompilation)(ptr)}
}
// Pointer returns the underlying pointer as unsafe.Pointer.
func (h *Compilation) Pointer() unsafe.Pointer {
return unsafe.Pointer(h.ptr)
}
// UintPtr returns the underlying pointer as a uintptr.
// This is useful for interop with gomobile bind, golang.org/x/mobile,
// gioui.org, and other packages that represent native handles as uintptr.
func (h *Compilation) UintPtr() uintptr {
return uintptr(unsafe.Pointer(h.ptr))
}
// NewCompilationFromUintPtr wraps a uintptr as a Compilation.
// The caller must ensure ptr points to a valid ANeuralNetworksCompilation.
func NewCompilationFromUintPtr(ptr uintptr) *Compilation {
return &Compilation{ptr: (*capi.ANeuralNetworksCompilation)(unsafe.Pointer(ptr))}
}
// NewBurst creates a new Burst from this Compilation.
func (h *Compilation) NewBurst() (*Burst, error) {
var ptr *capi.ANeuralNetworksBurst
if err := result(capi.ANeuralNetworksBurst_create(h.ptr, &ptr)); err != nil {
return nil, err
}
return &Burst{ptr: ptr}, nil
}
// Finish calls the underlying NDK function.
func (h *Compilation) Finish() error {
return result(capi.ANeuralNetworksCompilation_finish(h.ptr))
}
// SetCaching calls the underlying NDK function.
func (h *Compilation) SetCaching(cacheDir string, token *uint8) error {
return result(capi.ANeuralNetworksCompilation_setCaching(h.ptr, cacheDir, token))
}
// SetPreference calls the underlying NDK function.
func (h *Compilation) SetPreference(preference Preference) error {
return result(capi.ANeuralNetworksCompilation_setPreference(h.ptr, int32(preference)))
}
// SetPriority calls the underlying NDK function.
func (h *Compilation) SetPriority(priority int32) error {
return result(capi.ANeuralNetworksCompilation_setPriority(h.ptr, priority))
}
// SetTimeout calls the underlying NDK function.
func (h *Compilation) SetTimeout(duration uint64) error {
return result(capi.ANeuralNetworksCompilation_setTimeout(h.ptr, duration))
}
// NewExecution creates a new Execution from this Compilation.
func (h *Compilation) NewExecution() (*Execution, error) {
var ptr *capi.ANeuralNetworksExecution
if err := result(capi.ANeuralNetworksExecution_create(h.ptr, &ptr)); err != nil {
return nil, err
}
return &Execution{ptr: ptr}, nil
}