MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / c

Method c

tensorflow/go/context.go:41–65  ·  view source on GitHub ↗

c converts the ContextOptions to the C API's TF_ContextOptions. Caller takes ownership of returned object.

()

Source from the content-addressed store, hash-verified

39// c converts the ContextOptions to the C API's TF_ContextOptions.
40// Caller takes ownership of returned object.
41func (o *ContextOptions) c() (*C.TFE_ContextOptions, error) {
42 opt := C.TFE_NewContextOptions()
43 if o == nil {
44 return opt, nil
45 }
46
47 if sz := len(o.Config); sz > 0 {
48 status := newStatus()
49 cConfig := C.CBytes(o.Config)
50 C.TFE_ContextOptionsSetConfig(opt, cConfig, C.size_t(sz), status.c)
51 C.free(cConfig)
52 if err := status.Err(); err != nil {
53 C.TFE_DeleteContextOptions(opt)
54 return nil, fmt.Errorf("invalid ContextOptions.Config: %v", err)
55 }
56 }
57
58 var async uint8
59 if o.Async {
60 async = 1
61 }
62 C.TFE_ContextOptionsSetAsync(opt, C.uchar(async))
63
64 return opt, nil
65}
66
67// Context for executing operations eagerly.
68//

Callers 1

NewContextFunction · 0.45

Calls 3

newStatusFunction · 0.85
freeMethod · 0.80
ErrMethod · 0.45

Tested by

no test coverage detected