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.

debugger_tensor.py 2.3 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. """DebuggerTensor."""
  16. from abc import ABC
  17. class DebuggerTensor(ABC):
  18. """
  19. The tensor with specific rank, iteration and debugging info.
  20. Note:
  21. - Users should not instantiate this class manually.
  22. - The instances of this class is immutable.
  23. - A DebuggerTensor is always the output tensor of a node.
  24. """
  25. @property
  26. def node(self):
  27. """
  28. Get the node that outputs this tensor.
  29. Returns:
  30. Node, the node that outputs this tensor.
  31. """
  32. return None
  33. @property
  34. def name(self):
  35. """
  36. Get the name of this tensor.
  37. The name is composed of full name of a node and the slot number.
  38. Returns:
  39. str, the name of this tensor.
  40. """
  41. return ""
  42. @property
  43. def slot(self):
  44. """
  45. Get slot.
  46. Returns:
  47. int, the slot of the tensor on the node.
  48. """
  49. return -1
  50. @property
  51. def iteration(self):
  52. """
  53. Get the iteration for this tensor.
  54. Returns:
  55. int, the iteration for this tensor.
  56. """
  57. return -1
  58. @property
  59. def rank(self):
  60. """
  61. Get the rank for this tensor.
  62. Returns:
  63. int, the rank for this tensor.
  64. """
  65. return -1
  66. def get_value(self):
  67. """
  68. Get the value of the tensor.
  69. Returns:
  70. numpy.ndarray, the value of the debugger tensor.
  71. """
  72. def get_affected_nodes(self):
  73. """
  74. Get the nodes that use current tensor as input.
  75. """