コード例 #1
0
 def testOneTag(self):
   one_tag_string = "^^node:Two:${file}^^"
   interpolated_string = error_interpolation.interpolate(one_tag_string,
                                                         self.graph)
   self.assertTrue(interpolated_string.endswith("constant_op.py"),
                   "interpolated_string '%s' did not end with constant_op.py"
                   % interpolated_string)
コード例 #2
0
 def testNodeThreeHasColocationInterpolation(self):
     with ops.Graph().as_default():
         self._set_up_graph()
         message = "{{colocation_node Three_with_one}}"
         result = error_interpolation.interpolate(message,
                                                  ops.get_default_graph())
         self.assertIn("colocate_with(One)", result)
コード例 #3
0
 def testNodeZeroHasNoDeviceSummaryInfo(self):
     with ops.Graph().as_default():
         self.zero = constant_op.constant([0.0], name="zero")
         message = "{{colocation_node zero}}"
         result = error_interpolation.interpolate(message,
                                                  ops.get_default_graph())
         self.assertIn("No device assignments were active", result)
コード例 #4
0
 def testNothingToDo(self):
     with ops.Graph().as_default():
         constant_op.constant(1, name="One")
         normal_string = "This is just a normal string"
         interpolated_string = error_interpolation.interpolate(
             normal_string, ops.get_default_graph())
         self.assertIn(normal_string, interpolated_string)
コード例 #5
0
 def testNodeFourHasColocationInterpolationForNodeThreeOnly(self):
   message = "^^colocation_node:Four_with_three^^"
   result = error_interpolation.interpolate(message, self.graph)
   self.assertIn("colocate_with(Three_with_one)", result)
   self.assertNotIn(
       "One", result,
       "Node One should not appear in Four_with_three's summary:\n%s" % result)
コード例 #6
0
 def testOneTag(self):
   one_tag_string = "^^node:Two:${file}^^"
   interpolated_string = error_interpolation.interpolate(one_tag_string,
                                                         self.graph)
   self.assertTrue(interpolated_string.endswith("constant_op.py"),
                   "interpolated_string '%s' did not end with constant_op.py"
                   % interpolated_string)
コード例 #7
0
 def testNoInputs(self):
     two_tags_with_seps = ";;;{{node One}},,,{{node Two}};;;"
     interpolated_string = error_interpolation.interpolate(
         two_tags_with_seps, self.graph)
     expected_regex = (
         r"^;;;.*constant_op.py:[0-9]+\) ,,,.*constant_op.py:[0-9]+\) ;;;$")
     self.assertRegexpMatches(interpolated_string, expected_regex)
コード例 #8
0
 def testBasicInputs(self):
   tag = ";;;{{node Three}};;;"
   interpolated_string = error_interpolation.interpolate(tag, self.graph)
   expected_regex = re.compile(
       r"^;;;.*op_def_library.py:[0-9]+\) ;;;.*Input.*constant_op.py:[0-9]+\)",
       re.DOTALL)
   self.assertRegexpMatches(interpolated_string, expected_regex)
コード例 #9
0
 def testNoInputs(self):
   two_tags_with_seps = ";;;{{node One}},,,{{node Two}};;;"
   interpolated_string = error_interpolation.interpolate(
       two_tags_with_seps, self.graph)
   expected_regex = (
       r"^;;;.*constant_op.py:[0-9]+\) ,,,.*constant_op.py:[0-9]+\) ;;;$")
   self.assertRegexpMatches(interpolated_string, expected_regex)
コード例 #10
0
 def testBasicInputs(self):
     tag = ";;;{{node Three}};;;"
     interpolated_string = error_interpolation.interpolate(tag, self.graph)
     expected_regex = re.compile(
         r"^;;;.*op_def_library.py:[0-9]+\) ;;;.*Input.*constant_op.py:[0-9]+\)",
         re.DOTALL)
     self.assertRegexpMatches(interpolated_string, expected_regex)
コード例 #11
0
 def testTwoTagsWithSeps(self):
   two_tags_with_seps = ";;;^^node:Two^^,,,^^node:Three^^;;;"
   interpolated_string = error_interpolation.interpolate(
       two_tags_with_seps, self.graph)
   expected_regex = (
       r"^;;;.*constant_op.py:[0-9]+\) ,,,.*constant_op.py:[0-9]*\) ;;;$")
   self.assertRegexpMatches(interpolated_string, expected_regex)
コード例 #12
0
 def testTwoTagsNoSeps(self):
     two_tags_no_seps = "{{node One}}{{node Three}}"
     interpolated_string = error_interpolation.interpolate(
         two_tags_no_seps, self.graph)
     self.assertRegexpMatches(
         interpolated_string,
         "constant_op.py:[0-9]+.*constant_op.py:[0-9]+")
コード例 #13
0
 def testColocationInterpolationForNodeLackingColocation(self):
   with ops.Graph().as_default():
     self._set_up_graph()
     message = "{{colocation_node One}}"
     result = error_interpolation.interpolate(message, ops.get_default_graph())
     self.assertIn("No node-device colocations", result)
     self.assertNotIn("Two", result)
コード例 #14
0
 def testNodeOneHasExactlyOneInterpolatedDevice(self):
   with ops.Graph().as_default():
     with ops.device("/cpu"):
       self.one = constant_op.constant([1.0], name="one")
     message = "{{colocation_node one}}"
     result = error_interpolation.interpolate(message, ops.get_default_graph())
     self.assertEqual(2, result.count("tf.device(/cpu)"))
コード例 #15
0
 def testNodeFiveHasColocationInterpolationForNodeOneAndTwo(self):
   with ops.Graph().as_default():
     self._set_up_graph()
     message = "{{colocation_node Five_with_one_with_two}}"
     result = error_interpolation.interpolate(message, ops.get_default_graph())
     self.assertIn("colocate_with(One)", result)
     self.assertIn("colocate_with(Two)", result)
コード例 #16
0
 def testNodeTwoHasTwoInterpolatedDevice(self):
   message = "^^node:two:${devices}^^"
   result = error_interpolation.interpolate(message, self.graph)
   num_devices = result.count("tf.device")
   self.assertEqual(2, num_devices)
   self.assertIn("tf.device(/cpu)", result)
   self.assertIn("tf.device(/cpu:0)", result)
コード例 #17
0
 def testTwoTagsNoSeps(self):
     two_tags_no_seps = "{{node One}}{{node Three}}"
     interpolated_string = error_interpolation.interpolate(
         two_tags_no_seps, self.graph)
     self.assertRegex(
         interpolated_string, r"error_interpolation_test\.py:[0-9]+."
         r"*error_interpolation_test\.py:[0-9]+")
コード例 #18
0
 def testBasicInputs(self):
     tag = ";;;{{node Three}};;;"
     interpolated_string = error_interpolation.interpolate(tag, self.graph)
     expected_regex = re.compile(
         r"^;;;.*error_interpolation_test\.py:[0-9]+\) "
         r";;;.*Input.*error_interpolation_test\.py:[0-9]+\)", re.DOTALL)
     self.assertRegex(interpolated_string, expected_regex)
コード例 #19
0
 def testTwoTagsWithSeps(self):
     two_tags_with_seps = ";;;{{node Two}},,,{{node Three}};;;"
     interpolated_string = error_interpolation.interpolate(
         two_tags_with_seps, self.graph)
     expected_regex = (r"^;;;.*error_interpolation_test\.py:[0-9]+\) "
                       r",,,.*error_interpolation_test\.py:[0-9]+\) ;;;$")
     self.assertRegexpMatches(interpolated_string, expected_regex)
コード例 #20
0
 def testNodeTwoHasTwoInterpolatedDevice(self):
     message = "^^node:two:${devices}^^"
     result = error_interpolation.interpolate(message, self.graph)
     num_devices = result.count("tf.device")
     self.assertEqual(2, num_devices)
     self.assertIn("tf.device(/cpu)", result)
     self.assertIn("tf.device(/cpu:0)", result)
コード例 #21
0
 def testNodeThreeHasFancyFunctionDisplayNameForInterpolatedDevice(self):
   message = "^^colocation_node:three^^"
   result = error_interpolation.interpolate(message, self.graph)
   num_devices = result.count("tf.device")
   self.assertEqual(2, num_devices)
   name_re = r"_fancy_device_function<.*error_interpolation_test.py, [0-9]+>"
   expected_re = r"with tf.device\(.*%s\)" % name_re
   self.assertRegexpMatches(result, expected_re)
コード例 #22
0
 def testNodeFourHasColocationInterpolationForNodeThreeOnly(self):
   message = "^^node:Four_with_three:${colocations}^^"
   result = error_interpolation.interpolate(message, self.graph)
   assert_node_in_colocation_summary(self, result, name="Three_with_one")
   self.assertNotIn(
       "One", result,
       "Node One should not appear in Four_with_three's summary:\n%s"
       % result)
コード例 #23
0
 def testNodeTwoHasTwoInterpolatedDevice(self):
   with ops.Graph().as_default():
     with ops.device("/cpu"):
       with ops.device("/cpu:0"):
         self.two = constant_op.constant([2.0], name="two")
     message = "{{colocation_node two}}"
     result = error_interpolation.interpolate(message, ops.get_default_graph())
     self.assertEqual(2, result.count("tf.device(/cpu)"))
     self.assertEqual(2, result.count("tf.device(/cpu:0)"))
コード例 #24
0
 def testNewLine(self):
   with ops.Graph().as_default():
     constant_op.constant(1, name="One")
     constant_op.constant(2, name="Two")
     newline = "\n\n{{node One}}"
     interpolated_string = error_interpolation.interpolate(
         newline, ops.get_default_graph())
     self.assertRegex(interpolated_string,
                      r"error_interpolation_test\.py:[0-9]+.*")
コード例 #25
0
 def testNewLine(self):
   defined_at = r"\(defined at .*error_interpolation_test\.py:[0-9]+\)"
   with ops.Graph().as_default():
     constant_op.constant(1, name="One")
     constant_op.constant(2, name="Two")
     newline = "\n\n;;;{{node One}};;;"
     interpolated_string = error_interpolation.interpolate(
         newline, ops.get_default_graph())
     expected_regex = re.compile(r".*;;;.*" + defined_at + r".*;;;", re.DOTALL)
     self.assertRegex(interpolated_string, expected_regex)
コード例 #26
0
 def testNodeFourHasColocationInterpolationForNodeThreeOnly(self):
   with ops.Graph().as_default():
     self._set_up_graph()
     message = "{{colocation_node Four_with_three}}"
     result = error_interpolation.interpolate(message, ops.get_default_graph())
     self.assertIn("colocate_with(Three_with_one)", result)
     self.assertNotIn(
         "One", result,
         "Node One should not appear in Four_with_three's summary:\n%s" %
         result)
コード例 #27
0
 def testNoInputs(self):
   with ops.Graph().as_default():
     one = constant_op.constant(1, name="One")
     two = constant_op.constant(2, name="Two")
     _ = math_ops.add(one, two, name="Three")
     two_tags_with_seps = ";;;{{node One}},,,{{node Two}};;;"
     interpolated_string = error_interpolation.interpolate(
         two_tags_with_seps, ops.get_default_graph())
     expected_regex = (r"^;;;.*error_interpolation_test\.py:[0-9]+\) "
                       r",,,.*error_interpolation_test\.py:[0-9]+\) ;;;$")
     self.assertRegex(interpolated_string, expected_regex)
コード例 #28
0
 def testTwoTagsNoSeps(self):
   with ops.Graph().as_default():
     constant_op.constant(1, name="One")
     constant_op.constant(2, name="Two")
     constant_op.constant(3, name="Three")
     two_tags_no_seps = "{{node One}}{{node Three}}"
     interpolated_string = error_interpolation.interpolate(
         two_tags_no_seps, ops.get_default_graph())
     self.assertRegex(
         interpolated_string, r"error_interpolation_test\.py:[0-9]+."
         r"*error_interpolation_test\.py:[0-9]+")
コード例 #29
0
 def testNodeThreeHasFancyFunctionDisplayNameForInterpolatedDevice(self):
   with ops.Graph().as_default():
     with ops.device(self._fancy_device_function):
       self.three = constant_op.constant(3.0, name="three")
     message = "{{colocation_node three}}"
     result = error_interpolation.interpolate(message, ops.get_default_graph())
     num_devices = result.count("tf.device")
     self.assertEqual(2, num_devices)
     name_re = r"_fancy_device_function<.*error_interpolation_test.py, [0-9]+>"
     expected_re = r"with tf.device\(.*%s\)" % name_re
     self.assertRegex(result, expected_re)
コード例 #30
0
 def testTwoTagsNoSeps(self):
   defined_at = r"\(defined at .*error_interpolation_test\.py:[0-9]+\)"
   with ops.Graph().as_default():
     constant_op.constant(1, name="One")
     constant_op.constant(2, name="Two")
     constant_op.constant(3, name="Three")
     two_tags_no_seps = "{{node One}}{{node Three}}"
     interpolated_string = error_interpolation.interpolate(
         two_tags_no_seps, ops.get_default_graph())
     # Fragments the expression to avoid matching the pattern itself.
     expected_regex = re.compile(defined_at + r".*" + defined_at, re.DOTALL)
     self.assertRegex(interpolated_string, expected_regex)
コード例 #31
0
 def testBasicInputs(self):
   with ops.Graph().as_default():
     one = constant_op.constant(1, name="One")
     two = constant_op.constant(2, name="Two")
     _ = math_ops.add(one, two, name="Three")
     tag = ";;;{{node Three}};;;"
     interpolated_string = error_interpolation.interpolate(
         tag, ops.get_default_graph())
     expected_regex = re.compile(
         r"^;;;.*error_interpolation_test\.py:[0-9]+\) "
         r";;;.*Input.*error_interpolation_test\.py:[0-9]+\)", re.DOTALL)
     self.assertRegex(interpolated_string, expected_regex)
コード例 #32
0
 def testOperatorInputs(self):
   defined_at = r"\(defined at .*error_interpolation_test\.py:[0-9]+\)"
   with ops.Graph().as_default():
     one = constant_op.constant(1, name="One")
     two = constant_op.constant(2, name="Two")
     _ = math_ops.add(one, two, name="Three")
     tag = ";;;{{node Three}};;;"
     interpolated_string = error_interpolation.interpolate(
         tag, ops.get_default_graph())
     # Fragments the expression to avoid matching the pattern itself.
     expected_regex = re.compile(
         r"In\[0\] One " + defined_at + r".*"
         r"In\[1\] Two " + defined_at + r".*", re.DOTALL)
     self.assertRegex(interpolated_string, expected_regex)
コード例 #33
0
 def testTwoTagsWithSeps(self):
     defined_at = r"defined at.*error_interpolation_test\.py"
     with ops.Graph().as_default():
         constant_op.constant(1, name="One")
         constant_op.constant(2, name="Two")
         constant_op.constant(3, name="Three")
         two_tags_with_seps = ";;;{{node Two}},,,{{node Three}};;;"
         interpolated_string = error_interpolation.interpolate(
             two_tags_with_seps, ops.get_default_graph())
         # Fragments the expression to avoid matching the pattern itself.
         expected_regex = re.compile(
             rf"node 'Two'.*{defined_at}.*node 'Three'.*{defined_at}",
             re.DOTALL)
         self.assertRegex(interpolated_string, expected_regex)
コード例 #34
0
 def testOneTagWithAFakeFunctionTag(self):
     defined_at = r"defined at.*error_interpolation_test\.py"
     with ops.Graph().as_default():
         constant_op.constant(1, name="One")
         constant_op.constant(2, name="Two")
         one_tag_with_a_fake_function_tag = "{{function_node fake}}{{node One}}"
         interpolated_string = error_interpolation.interpolate(
             one_tag_with_a_fake_function_tag, ops.get_default_graph())
         # Fragments the expression to avoid matching the pattern itself.
         expected_regex = re.compile(rf"node 'One'.*{defined_at}",
                                     re.DOTALL)
         self.assertRegex(interpolated_string, expected_regex)
         self.assertNotIn("function_node", interpolated_string)
         self.assertNotIn("node 'Two'", interpolated_string)
コード例 #35
0
 def testOneTag(self):
   one_tag_string = "^^node:Foo:${file}^^"
   interpolated_string = error_interpolation.interpolate(one_tag_string)
   self.assertEqual(interpolated_string, "${file}")
コード例 #36
0
 def testTwoTagsWithSeps(self):
   two_tags_with_seps = "123^^node:Foo:${file}^^456^^node:Bar:${line}^^789"
   interpolated_string = error_interpolation.interpolate(two_tags_with_seps)
   self.assertEqual(interpolated_string, "123${file}456${line}789")
コード例 #37
0
 def testNodeFiveHasColocationInterpolationForNodeOneAndTwo(self):
   message = "^^colocation_node:Five_with_one_with_two^^"
   result = error_interpolation.interpolate(message, self.graph)
   self.assertIn("colocate_with(One)", result)
   self.assertIn("colocate_with(Two)", result)
コード例 #38
0
 def testColocationInterpolationForNodeLackingColocation(self):
   message = "^^colocation_node:One^^"
   result = error_interpolation.interpolate(message, self.graph)
   self.assertIn("No node-device colocations", result)
   self.assertNotIn("Two", result)
コード例 #39
0
 def testNodeThreeHasColocationInterpolation(self):
   message = "^^colocation_node:Three_with_one^^"
   result = error_interpolation.interpolate(message, self.graph)
   self.assertIn("colocate_with(One)", result)
コード例 #40
0
 def testTwoTagsWithSeps(self):
   two_tags_with_seps = ";;;^^node:Two:${file}^^,,,^^node:Three:${line}^^;;;"
   interpolated_string = error_interpolation.interpolate(two_tags_with_seps,
                                                         self.graph)
   expected_regex = "^;;;.*constant_op.py,,,[0-9]*;;;$"
   self.assertRegexpMatches(interpolated_string, expected_regex)
コード例 #41
0
 def testNodeTwoHasTwoInterpolatedDevice(self):
   message = "^^colocation_node:two^^"
   result = error_interpolation.interpolate(message, self.graph)
   self.assertEqual(2, result.count("tf.device(/cpu)"))
   self.assertEqual(2, result.count("tf.device(/cpu:0)"))
コード例 #42
0
 def testNodeOneHasExactlyOneInterpolatedDevice(self):
   message = "^^node:one:${devices}^^"
   result = error_interpolation.interpolate(message, self.graph)
   num_devices = result.count("tf.device")
   self.assertEqual(1, num_devices)
   self.assertIn("tf.device(/cpu)", result)
コード例 #43
0
 def testNodeZeroHasNoDeviceSummaryInfo(self):
   message = "^^colocation_node:zero^^"
   result = error_interpolation.interpolate(message, self.graph)
   self.assertIn("No device assignments were active", result)
コード例 #44
0
 def testNodeOneHasExactlyOneInterpolatedDevice(self):
   message = "^^colocation_node:one^^"
   result = error_interpolation.interpolate(message, self.graph)
   self.assertEqual(2, result.count("tf.device(/cpu)"))
コード例 #45
0
 def testTwoTagsNoSeps(self):
   two_tags_no_seps = "^^node:Foo:${file}^^^^node:Bar:${line}^^"
   interpolated_string = error_interpolation.interpolate(two_tags_no_seps)
   self.assertEqual(interpolated_string, "${file}${line}")
コード例 #46
0
 def testTwoTagsNoSeps(self):
   two_tags_no_seps = "^^node:One^^^^node:Three^^"
   interpolated_string = error_interpolation.interpolate(
       two_tags_no_seps, self.graph)
   self.assertRegexpMatches(interpolated_string,
                            "constant_op.py:[0-9]+.*constant_op.py:[0-9]+")
コード例 #47
0
 def testOneTagWithAFakeNameResultsInPlaceholders(self):
   one_tag_string = "^^node:MinusOne^^"
   interpolated_string = error_interpolation.interpolate(
       one_tag_string, self.graph)
   self.assertEqual(one_tag_string, interpolated_string)
コード例 #48
0
 def testNothingToDo(self):
   normal_string = "This is just a normal string"
   interpolated_string = error_interpolation.interpolate(
       normal_string, self.graph)
   self.assertEqual(interpolated_string, normal_string)
コード例 #49
0
 def testNewLine(self):
   newline = "\n\n{{node One}}"
   interpolated_string = error_interpolation.interpolate(newline, self.graph)
   self.assertRegexpMatches(interpolated_string, "constant_op.py:[0-9]+.*")