c converts the ContextOptions to the C API's TF_ContextOptions. Caller takes ownership of returned object.
()
| 39 | // c converts the ContextOptions to the C API's TF_ContextOptions. |
| 40 | // Caller takes ownership of returned object. |
| 41 | func (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 | // |
no test coverage detected