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

Method session

tensorflow/compiler/tests/xla_test.py:204–224  ·  view source on GitHub ↗

Custom implementation of session() for XLA tests. We override the standard Tensorflow session() since it is too specific to CPU and GPU tests. In particular, we want to disable soft placement and explicitly assign ops to devices under test. Yields: A session to use when runni

(self)

Source from the content-addressed store, hash-verified

202
203 @contextlib.contextmanager
204 def session(self):
205 """Custom implementation of session() for XLA tests.
206
207 We override the standard Tensorflow session() since it is too
208 specific to CPU and GPU tests. In particular, we want to disable soft
209 placement and explicitly assign ops to devices under test.
210
211 Yields:
212 A session to use when running a test case.
213 """
214 graph = ops.Graph()
215 config = context.context().config
216
217 # Grappler can constant fold TensorListFromTensor ops into DT_VARIANT
218 # constants which XLA does not understand. So disable constant folding in
219 # these tests.
220 config.graph_options.rewrite_options.constant_folding = (
221 rewriter_config_pb2.RewriterConfig.OFF)
222 with session.Session(
223 graph=graph, config=config) as sess, graph.as_default():
224 yield sess
225
226 def cached_session(self):
227 raise NotImplementedError(

Callers 15

testTopKZerosMethod · 0.45
testTopKInfinitiesMethod · 0.45
_testSvdCorrectnessMethod · 0.45
testBasicMethod · 0.45
testSharingMethod · 0.45
testEnqueueMethod · 0.45
testEnqueueWithShapeMethod · 0.45

Calls 4

as_defaultMethod · 0.95
GraphMethod · 0.45
contextMethod · 0.45
SessionMethod · 0.45

Tested by

no test coverage detected