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

Function deviceSliceFromDeviceList

tensorflow/go/session.go:83–113  ·  view source on GitHub ↗
(list *C.TF_DeviceList)

Source from the content-addressed store, hash-verified

81}
82
83func deviceSliceFromDeviceList(list *C.TF_DeviceList) ([]Device, error) {
84 var devices []Device
85 status := newStatus()
86
87 for i := 0; i < int(C.TF_DeviceListCount(list)); i++ {
88 name := C.TF_DeviceListName(list, C.int(i), status.c)
89 if err := status.Err(); err != nil {
90 return nil, fmt.Errorf("DeviceListName(index=%d) failed: %v", i, err)
91 }
92
93 deviceType := C.TF_DeviceListType(list, C.int(i), status.c)
94 if err := status.Err(); err != nil {
95 return nil, fmt.Errorf("DeviceListType(index=%d) failed: %v", i, err)
96 }
97
98 memoryLimitBytes := C.TF_DeviceListMemoryBytes(list, C.int(i), status.c)
99 if err := status.Err(); err != nil {
100 return nil, fmt.Errorf("DeviceListMemoryBytes(index=%d) failed: %v", i, err)
101 }
102
103 device := Device{
104 Name: C.GoString(name),
105 Type: C.GoString(deviceType),
106 MemoryLimitBytes: int64(memoryLimitBytes),
107 }
108
109 devices = append(devices, device)
110 }
111
112 return devices, nil
113}
114
115// ListDevices returns the list of devices associated with a Session.
116func (s *Session) ListDevices() ([]Device, error) {

Callers 2

ListDevicesMethod · 0.85
ListDevicesMethod · 0.85

Calls 4

newStatusFunction · 0.85
int64Function · 0.85
appendFunction · 0.85
ErrMethod · 0.45

Tested by

no test coverage detected