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

Method compiled

tensorflow/python/autograph/core/converter_testing.py:55–92  ·  view source on GitHub ↗
(self, node, namespace, symbols=())

Source from the content-addressed store, hash-verified

53
54 @contextlib.contextmanager
55 def compiled(self, node, namespace, symbols=()):
56 source = None
57
58 self.dynamic_calls = []
59 # See api.converted_call
60 def converted_call(f, unused_opts, args, kwargs, unused_function_ctx):
61 """Mock version of api.converted_call."""
62 self.dynamic_calls.append((args, kwargs))
63 if kwargs is None:
64 kwargs = {}
65 return f(*args, **kwargs)
66
67 try:
68 result, source, source_map = compiler.ast_to_object(
69 node, include_source_map=True)
70 # TODO(mdan): Move the unparsing from converter into pyct and reuse here.
71
72 # TODO(mdan): Move this into self.prepare()
73 result.tf = self.make_fake_mod('fake_tf', *symbols)
74 fake_ag = self.make_fake_mod('fake_ag', converted_call,
75 converter.ConversionOptions)
76 fake_ag.__dict__.update(operators.__dict__)
77 fake_ag.__dict__.update(special_functions.__dict__)
78 fake_ag.ConversionOptions = converter.ConversionOptions
79 fake_ag.Feature = converter.Feature
80 fake_ag.utils = utils
81 fake_ag.FunctionScope = function_wrappers.FunctionScope
82 result.ag__ = fake_ag
83 result.ag_source_map__ = source_map
84 for k, v in namespace.items():
85 result.__dict__[k] = v
86 yield result
87 except Exception: # pylint:disable=broad-except
88 if source is None:
89 print('Offending AST:\n%s' % pretty_printer.fmt(node, color=False))
90 else:
91 print('Offending compiled code:\n%s' % source)
92 raise
93
94 @contextlib.contextmanager
95 def converted(self, entity, converter_module, namespace, tf_symbols=()):

Callers 6

convertedMethod · 0.95
test_list_popMethod · 0.80
test_list_stackMethod · 0.80
test_methodMethod · 0.80
test_index_accessMethod · 0.80

Calls 2

make_fake_modMethod · 0.95
updateMethod · 0.45

Tested by

no test coverage detected