Parses **kwargs into a node's attributes.
(func_name, **kwargs)
| 1197 | |
| 1198 | |
| 1199 | def _parse_kwargs_as_attrs(func_name, **kwargs): |
| 1200 | """Parses **kwargs into a node's attributes.""" |
| 1201 | attrs = {} |
| 1202 | |
| 1203 | noinline = kwargs.pop("noinline", None) |
| 1204 | if noinline is not None: |
| 1205 | attrs["_noinline"] = attr_value_pb2.AttrValue(b=bool(noinline)) |
| 1206 | |
| 1207 | # For compatibility with previous behavior, Defun does not perform shape |
| 1208 | # inference through its function call operations. |
| 1209 | attrs["_disable_call_shape_inference"] = attr_value_pb2.AttrValue(b=True) |
| 1210 | |
| 1211 | compiled = kwargs.pop("compiled", None) |
| 1212 | separate_compiled_gradients = kwargs.pop("separate_compiled_gradients", None) |
| 1213 | if compiled is not None: |
| 1214 | attrs["_XlaCompile"] = attr_value_pb2.AttrValue(b=bool(compiled)) |
| 1215 | attrs["_XlaSeparateCompiledGradients"] = attr_value_pb2.AttrValue( |
| 1216 | b=bool(separate_compiled_gradients)) |
| 1217 | # Forward _XlaScope from enclosing context (if set), otherwise create new. |
| 1218 | # pylint: disable=protected-access |
| 1219 | if "_XlaScope" in ops.get_default_graph()._attr_scope_map: |
| 1220 | attrs["_XlaScope"] = ops.get_default_graph()._attr_scope_map["_XlaScope"] |
| 1221 | else: |
| 1222 | attrs["_XlaScope"] = attr_value_pb2.AttrValue( |
| 1223 | s=("function_%s" % func_name).encode()) |
| 1224 | # pylint: enable=protected-access |
| 1225 | |
| 1226 | kwargs_keys = list(kwargs.keys()) |
| 1227 | for key in kwargs_keys: |
| 1228 | if key.startswith("experimental_"): |
| 1229 | attrs[key] = _get_experimental_kwarg_as_attr(key, kwargs[key]) |
| 1230 | del kwargs[key] |
| 1231 | # Support for https://github.com/tensorflow/community/pull/113/files. |
| 1232 | elif key == "_implements" or key == "_reference": |
| 1233 | attrs[key] = _get_kwarg_as_str_attr(key, kwargs[key]) |
| 1234 | del kwargs[key] |
| 1235 | if kwargs: |
| 1236 | raise ValueError("Unknown keyword arguments: %s" % kwargs.keys()) |
| 1237 | return attrs |
| 1238 | |
| 1239 | |
| 1240 | def get_extra_vars(): |
no test coverage detected