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.

tensor_sanity_check.py 791 B

12345678910111213141516171819202122232425262728293031
  1. from ..core._imperative_rt import TensorSanityCheckImpl
  2. from ..core._imperative_rt.imperative import sync
  3. class TensorSanityCheck:
  4. r"""An object that checks whether the input tensors of each operator have changed before and after the operation.
  5. Examples:
  6. .. code-block:: python
  7. from megengine import tensor
  8. from megengine.utils.tensor_sanity_check import TensorSanityCheck
  9. with TensorSanityCheck() as checker:
  10. a = tensor([1, 2])
  11. b = tensor([3, 4])
  12. c = a + b
  13. """
  14. def __init__(self):
  15. self.impl = TensorSanityCheckImpl()
  16. def __enter__(self):
  17. sync()
  18. self.impl.enable()
  19. return self
  20. def __exit__(self, val, type, trace):
  21. sync()
  22. self.impl.disable()

MegEngine 安装包中集成了使用 GPU 运行代码所需的 CUDA 环境,不用区分 CPU 和 GPU 版。 如果想要运行 GPU 程序,请确保机器本身配有 GPU 硬件设备并安装好驱动。 如果你想体验在云端 GPU 算力平台进行深度学习开发的感觉,欢迎访问 MegStudio 平台