Create a NodeDef proto. Args: op_type: Value for the "op" attribute of the NodeDef proto. name: Value for the "name" attribute of the NodeDef proto. device: string, device, or function from NodeDef to string. Value for the "device" attribute of the NodeDef proto. attrs: Opti
(op_type, name, device=None, attrs=None)
| 1530 | |
| 1531 | |
| 1532 | def _NodeDef(op_type, name, device=None, attrs=None): # pylint: disable=redefined-outer-name |
| 1533 | """Create a NodeDef proto. |
| 1534 | |
| 1535 | Args: |
| 1536 | op_type: Value for the "op" attribute of the NodeDef proto. |
| 1537 | name: Value for the "name" attribute of the NodeDef proto. |
| 1538 | device: string, device, or function from NodeDef to string. Value for the |
| 1539 | "device" attribute of the NodeDef proto. |
| 1540 | attrs: Optional dictionary where the key is the attribute name (a string) |
| 1541 | and the value is the respective "attr" attribute of the NodeDef proto (an |
| 1542 | AttrValue). |
| 1543 | |
| 1544 | Returns: |
| 1545 | A node_def_pb2.NodeDef protocol buffer. |
| 1546 | """ |
| 1547 | node_def = node_def_pb2.NodeDef() |
| 1548 | node_def.op = compat.as_bytes(op_type) |
| 1549 | node_def.name = compat.as_bytes(name) |
| 1550 | if attrs is not None: |
| 1551 | for k, v in six.iteritems(attrs): |
| 1552 | node_def.attr[k].CopyFrom(v) |
| 1553 | if device is not None: |
| 1554 | if callable(device): |
| 1555 | node_def.device = device(node_def) |
| 1556 | else: |
| 1557 | node_def.device = _device_string(device) |
| 1558 | return node_def |
| 1559 | |
| 1560 | |
| 1561 | # Copied from core/framework/node_def_util.cc |
no test coverage detected