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

Method Attr

tensorflow/go/attrs.go:38–52  ·  view source on GitHub ↗

Attr returns the value of an attribute on op. It returns an error if the attribute does not exist.

(name string)

Source from the content-addressed store, hash-verified

36// Attr returns the value of an attribute on op. It returns an error if the
37// attribute does not exist.
38func (op *Operation) Attr(name string) (interface{}, error) {
39 cname := C.CString(name)
40 defer C.free(unsafe.Pointer(cname))
41
42 status := newStatus()
43 meta := C.TF_OperationGetAttrMetadata(op.c, cname, status.c)
44 if err := status.Err(); err != nil {
45 return nil, err
46 }
47
48 if meta.is_list == 1 {
49 return listAttribute(op, cname, meta)
50 }
51 return scalarAttribute(op, cname, meta)
52}
53
54func listAttribute(op *Operation, cname *C.char, meta C.TF_AttrMetadata) (interface{}, error) {
55 status := newStatus()

Callers 15

TESTFunction · 0.45
lookup_ops.ccFile · 0.45
mainFunction · 0.45
TESTFunction · 0.45
invalid_op.ccFile · 0.45
test_ops.ccFile · 0.45
TestOperationAttrsFunction · 0.45
attr_examples.ccFile · 0.45
unit_test_ops.ccFile · 0.45

Calls 5

newStatusFunction · 0.85
listAttributeFunction · 0.85
scalarAttributeFunction · 0.85
freeMethod · 0.80
ErrMethod · 0.45

Tested by 4

TESTFunction · 0.36
mainFunction · 0.36
TESTFunction · 0.36
TestOperationAttrsFunction · 0.36