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

Function convert

tensorflow/python/autograph/impl/conversion.py:306–324  ·  view source on GitHub ↗

Converts an entity into an equivalent entity.

(entity, program_ctx)

Source from the content-addressed store, hash-verified

304
305
306def convert(entity, program_ctx):
307 """Converts an entity into an equivalent entity."""
308
309 if tf_inspect.isfunction(entity) or tf_inspect.ismethod(entity):
310 free_nonglobal_var_names = entity.__code__.co_freevars
311 else:
312 free_nonglobal_var_names = ()
313
314 for i, name in enumerate(free_nonglobal_var_names):
315 if (name == 'ag__' and
316 entity.__closure__[i].cell_contents is not ag_internal):
317 raise ValueError('entity {} uses the reserved symbol "{}"'.format(
318 entity, name))
319 # TODO(mdan): In extreme cases, other ag__ symbols may also be clobbered.
320
321 converted_entity_info = _convert_with_cache(entity, program_ctx,
322 free_nonglobal_var_names)
323
324 return _instantiate(entity, converted_entity_info, free_nonglobal_var_names)
325
326
327# TODO(mdan): allow_namedtuple_subclass should be hardcoded to True.

Callers

nothing calls this directly

Calls 3

_convert_with_cacheFunction · 0.85
_instantiateFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected