Browse Source

fix(mge): replace _full_sync by sync

GitOrigin-RevId: e36ef45464
tags/v1.8.0
Megvii Engine Team 3 years ago
parent
commit
8b60bdfa10
3 changed files with 9 additions and 9 deletions
  1. +1
    -1
      imperative/python/megengine/__init__.py
  2. +6
    -6
      imperative/python/megengine/device.py
  3. +2
    -2
      imperative/python/megengine/tools/benchmark_op.py

+ 1
- 1
imperative/python/megengine/__init__.py View File

@@ -76,7 +76,7 @@ if sys.platform == "win32":
kernel32.SetErrorMode(old_error_mode) kernel32.SetErrorMode(old_error_mode)


from .core._imperative_rt.core2 import close as _close from .core._imperative_rt.core2 import close as _close
from .core._imperative_rt.core2 import full_sync as _full_sync
from .core._imperative_rt.core2 import full_sync as sync
from .core._imperative_rt.core2 import sync as _sync from .core._imperative_rt.core2 import sync as _sync
from .core._imperative_rt.utils import _set_fork_exec_path_for_timed_func from .core._imperative_rt.utils import _set_fork_exec_path_for_timed_func
from .device import * from .device import *


+ 6
- 6
imperative/python/megengine/device.py View File

@@ -165,7 +165,7 @@ def get_cuda_compute_capability(device: int, device_type=DeviceType.CUDA) -> int
def get_allocated_memory(device: Optional[str] = None): def get_allocated_memory(device: Optional[str] = None):
r"""Returns the current memory occupied by tensors on the computing device in bytes. r"""Returns the current memory occupied by tensors on the computing device in bytes.


Due to the asynchronous execution of MegEngine, please call megengine._full_sync
Due to the asynchronous execution of MegEngine, please call megengine.sync
before calling this function in order to get accurate value. before calling this function in order to get accurate value.
""" """
if device is None: if device is None:
@@ -176,7 +176,7 @@ def get_allocated_memory(device: Optional[str] = None):
def get_reserved_memory(device: Optional[str] = None): def get_reserved_memory(device: Optional[str] = None):
r"""Returns the current memory managed by the caching allocator on the computing device in bytes. r"""Returns the current memory managed by the caching allocator on the computing device in bytes.


Due to the asynchronous execution of MegEngine, please call megengine._full_sync
Due to the asynchronous execution of MegEngine, please call megengine.sync
before calling this function in order to get accurate value. before calling this function in order to get accurate value.
""" """
if device is None: if device is None:
@@ -187,7 +187,7 @@ def get_reserved_memory(device: Optional[str] = None):
def get_max_reserved_memory(device: Optional[str] = None): def get_max_reserved_memory(device: Optional[str] = None):
r"""Returns the maximum memory managed by the caching allocator on the computing device in bytes. r"""Returns the maximum memory managed by the caching allocator on the computing device in bytes.


Due to the asynchronous execution of MegEngine, please call megengine._full_sync
Due to the asynchronous execution of MegEngine, please call megengine.sync
before calling this function in order to get accurate value. before calling this function in order to get accurate value.
""" """
if device is None: if device is None:
@@ -198,7 +198,7 @@ def get_max_reserved_memory(device: Optional[str] = None):
def get_max_allocated_memory(device: Optional[str] = None): def get_max_allocated_memory(device: Optional[str] = None):
r"""Returns the maximum memory occupied by tensors on the computing device in bytes. r"""Returns the maximum memory occupied by tensors on the computing device in bytes.


Due to the asynchronous execution of MegEngine, please call megengine._full_sync
Due to the asynchronous execution of MegEngine, please call megengine.sync
before calling this function in order to get accurate value. before calling this function in order to get accurate value.
""" """
if device is None: if device is None:
@@ -209,7 +209,7 @@ def get_max_allocated_memory(device: Optional[str] = None):
def reset_max_memory_stats(device: Optional[str] = None): def reset_max_memory_stats(device: Optional[str] = None):
r"""Resets the maximum stats on the computing device. r"""Resets the maximum stats on the computing device.


Due to the asynchronous execution of MegEngine, please call megengine._full_sync
Due to the asynchronous execution of MegEngine, please call megengine.sync
before calling this function in order to properly reset memory stats. before calling this function in order to properly reset memory stats.
""" """
if device is None: if device is None:
@@ -255,7 +255,7 @@ def coalesce_free_memory():
small pieces may not be returned. small pieces may not be returned.
because of the async processing of megengine, the effect of this func may not be reflected because of the async processing of megengine, the effect of this func may not be reflected
immediately. if you want to see the effect immediately, you can call megengine._full_sync after
immediately. if you want to see the effect immediately, you can call megengine.sync after
this func was called this func was called


.. note:: .. note::


+ 2
- 2
imperative/python/megengine/tools/benchmark_op.py View File

@@ -400,14 +400,14 @@ test_cases = [


def perf_func(func, inps, reps, unpack_inps, is_mge): def perf_func(func, inps, reps, unpack_inps, is_mge):
if is_mge: if is_mge:
mge._full_sync()
mge.sync()
tik = time.time() tik = time.time()
for _ in range(reps): for _ in range(reps):
if unpack_inps: if unpack_inps:
out = func(*inps) out = func(*inps)
else: else:
out = func(inps) out = func(inps)
mge._full_sync()
mge.sync()
else: else:
torch.cuda.synchronize() torch.cuda.synchronize()
with torch.no_grad(): with torch.no_grad():


Loading…
Cancel
Save