You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_debug_api.py 2.6 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # Copyright 2021 Huawei Technologies Co., Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ==============================================================================
  15. """Test debug API."""
  16. import pytest
  17. from mindspore.offline_debug.dump_analyzer import DumpAnalyzer
  18. from mindspore.offline_debug.watchpoints import TensorTooLargeWatchpoint
  19. @pytest.mark.skip(reason="Feature under development.")
  20. def test_export_graphs():
  21. """Test debug API."""
  22. my_run = DumpAnalyzer(
  23. summary_dir="/path/to/summary-dir1"
  24. )
  25. # Export the info about computational graph. Should support multi graphs.
  26. my_run.export_graphs()
  27. @pytest.mark.skip(reason="Feature under development.")
  28. def test_select_tensors():
  29. """Test debug API."""
  30. my_run = DumpAnalyzer(
  31. summary_dir="/path/to/summary-dir2"
  32. )
  33. # Find the interested tensors.
  34. matched_tensors = my_run.select_tensors(".*conv1.*", use_regex=True)
  35. assert matched_tensors == []
  36. @pytest.mark.skip(reason="Feature under development.")
  37. def test_check_watchpoints_all_iterations():
  38. """Test debug API."""
  39. my_run = DumpAnalyzer(
  40. summary_dir="/path/to/summary-dir3"
  41. )
  42. # Checking all the iterations.
  43. watchpoints = [
  44. TensorTooLargeWatchpoint(
  45. tensors=my_run.select_tensors(
  46. "(*.weight^)|(*.bias^)", use_regex=True),
  47. abs_mean_gt=0.1)
  48. ]
  49. watch_point_hits = my_run.check_watchpoints(watchpoints=watchpoints)
  50. assert watch_point_hits == []
  51. @pytest.mark.skip(reason="Feature under development.")
  52. def test_check_watchpoints_one_iteration():
  53. """Test debug API."""
  54. my_run = DumpAnalyzer(
  55. summary_dir="/path/to/summary-dir4"
  56. )
  57. # Checking specific iteration.
  58. watchpoints = [
  59. TensorTooLargeWatchpoint(
  60. tensors=my_run.select_tensors(
  61. "(*.weight^)|(*.bias^)", use_regex=True,
  62. iterations=[1]),
  63. abs_mean_gt=0.1)
  64. ]
  65. watch_point_hits = my_run.check_watchpoints(watchpoints=watchpoints)
  66. assert watch_point_hits == []