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

Method Get

tensorflow/go/genop/internal/api_def_map.go:100–127  ·  view source on GitHub ↗

Returns ApiDef proto instance for the TensorFlow operation named `opname`.

(opname string)

Source from the content-addressed store, hash-verified

98// Returns ApiDef proto instance for the TensorFlow operation
99// named `opname`.
100func (m *apiDefMap) Get(opname string) (*pb.ApiDef, error) {
101 cname := C.CString(opname)
102 defer C.free(unsafe.Pointer(cname))
103 status := C.TF_NewStatus()
104 defer C.TF_DeleteStatus(status)
105 apidefBuf := C.TF_ApiDefMapGet(
106 m.c, cname, C.size_t(len(opname)), status)
107 defer C.TF_DeleteBuffer(apidefBuf)
108 if C.TF_GetCode(status) != C.TF_OK {
109 return nil, errors.New(C.GoString(C.TF_Message(status)))
110 }
111 if apidefBuf == nil {
112 return nil, fmt.Errorf("could not find ApiDef for %s", opname)
113 }
114
115 var (
116 apidef = new(pb.ApiDef)
117 size = int(apidefBuf.length)
118 // A []byte backed by C memory.
119 // See: https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices
120 data = (*[1 << 30]byte)(unsafe.Pointer(apidefBuf.data))[:size:size]
121 err = proto.Unmarshal(data, apidef)
122 )
123 if err != nil {
124 return nil, err
125 }
126 return apidef, nil
127}

Callers 3

downloadFunction · 0.45
generateFunctionsForOpsFunction · 0.45
GetAPIDefFunction · 0.45

Calls 2

freeMethod · 0.80
NewMethod · 0.45

Tested by 2

downloadFunction · 0.36
GetAPIDefFunction · 0.36