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

Method test_compile

tensorflow/contrib/compiler/xla_test.py:81–96  ·  view source on GitHub ↗

Calls model_fn and verifies it is compiled.

(self, model_fn, params)

Source from the content-addressed store, hash-verified

79 }),
80 )
81 def test_compile(self, model_fn, params):
82 """Calls model_fn and verifies it is compiled."""
83 with test.mock.patch.object(xla, 'compile') as mock_xla_compile:
84 loss = constant_op.constant(_EXPECTED_LOSS)
85 mock_xla_compile.return_value = [loss]
86
87 features, labels = make_dummy_features_labels()
88 estimator_spec = model_fn(
89 features=features, labels=labels, mode=_TRAIN, params=params or {})
90
91 self.assertEqual(mock_xla_compile.call_count, 1)
92 self.assertEqual(estimator_spec.mode, _TRAIN)
93
94 with self.test_session() as sess:
95 self.assertEqual(sess.run(estimator_spec.loss), sess.run(loss))
96 self.assertEqual(sess.run(estimator_spec.train_op), sess.run(loss))
97
98 @parameterized.named_parameters(
99 ('test_use_tpu_true_hparams', decorated_model_fn,

Callers

nothing calls this directly

Calls 5

model_fnFunction · 0.50
constantMethod · 0.45
test_sessionMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected