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

Method test_datastructures

tensorflow/python/saved_model/save_test.py:312–331  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

310 _import_and_infer(save_dir, {"x": 3.}))
311
312 def test_datastructures(self):
313
314 class HasDatastructures(util.Checkpoint):
315
316 def __init__(self):
317 self.a = [1.]
318 self.a.append(variables.Variable(2.))
319 self.b = {"a": variables.Variable(3.)}
320
321 @def_function.function(input_signature=[tensor_spec.TensorSpec(
322 shape=None, dtype=dtypes.float32)])
323 def add(self, x):
324 return x + math_ops.add_n(self.a) + self.b["a"]
325
326 to_save = HasDatastructures()
327 to_save.add(constant_op.constant(1.))
328 save_dir = os.path.join(self.get_temp_dir(), "saved_model")
329 save.save(to_save, save_dir)
330 self.assertAllClose({"output_0": 10.},
331 _import_and_infer(save_dir, {"x": 4.}))
332
333 def test_default_attr_stripping(self):
334

Callers

nothing calls this directly

Calls 8

addMethod · 0.95
HasDatastructuresClass · 0.85
get_temp_dirMethod · 0.80
_import_and_inferFunction · 0.70
constantMethod · 0.45
joinMethod · 0.45
saveMethod · 0.45
assertAllCloseMethod · 0.45

Tested by

no test coverage detected