Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip cpu autotest for graph global #8593

Merged
merged 6 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/oneflow/test/modules/test_consistent_0_dim_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from oneflow.test_utils.automated_test_util import *


@autotest(n=1, check_graph=False)
@autotest(n=1, check_graph=True)
def _test_0_dim_tensor(test_case, placement, sbp):
x1 = random_tensor(0).to_global(placement=placement, sbp=sbp)
x2 = random_tensor(0).to_global(placement=placement, sbp=sbp)
Expand All @@ -29,7 +29,7 @@ def _test_0_dim_tensor(test_case, placement, sbp):
return y1 + y2


@autotest(n=1, check_graph=False)
@autotest(n=1, check_graph=True)
def _test_1dim_slice(test_case, placement, sbp):
x = random_tensor(1, random(1, 4) * 8).to_global(placement=placement, sbp=sbp)
return x[5]
Expand Down
2 changes: 1 addition & 1 deletion python/oneflow/test/modules/test_consistent_abs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import oneflow.unittest


@autotest(n=1, check_graph=False)
@autotest(n=1, check_graph=True)
def _test_abs_with_ndim_data(test_case, ndim, placement, sbp):
dims = [random(1, 3) * 8 for i in range(ndim)]
x = random_tensor(ndim, *dims).to_global(placement=placement, sbp=sbp)
Expand Down
4 changes: 2 additions & 2 deletions python/oneflow/test/modules/test_consistent_adaptive_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
]


@autotest(n=1, check_graph=False)
@autotest(n=1, check_graph=True)
def _test_adaptive_avgpoolnd(test_case, ndim, pool_size, placement, sbp):
dims = [random(1, 3) * 8 for i in range(ndim)]
x = random_tensor(ndim, *dims).to_global(placement=placement, sbp=sbp)
Expand All @@ -48,7 +48,7 @@ def _test_adaptive_avgpoolnd(test_case, ndim, pool_size, placement, sbp):
return y


@autotest(n=1, check_graph=False)
@autotest(n=1, check_graph=True)
def _test_adaptive_avgpoolnd_functional(test_case, ndim, pool_size, placement, sbp):
dims = [random(1, 3) * 8 for i in range(ndim)]
x = random_tensor(ndim, *dims).to_global(placement=placement, sbp=sbp)
Expand Down
2 changes: 1 addition & 1 deletion python/oneflow/test/modules/test_consistent_chunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from oneflow.test_utils.automated_test_util import *


@autotest(n=1, check_graph=False)
@autotest(n=1, check_graph=True)
def _test_chunk(test_case, ndim, placement, sbp):
dims = [random(1, 3).to(int) * 8 for _ in range(ndim)]
x = random_tensor(ndim, *dims).to_global(placement=placement, sbp=sbp)
Expand Down
2 changes: 1 addition & 1 deletion python/oneflow/test/modules/test_consistent_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from oneflow.test_utils.automated_test_util import *


@autotest(n=1, check_graph=False)
@autotest(n=1, check_graph=True)
def do_test_diag_impl(test_case, ndim, placement, sbp):
dims = [random(1, 4) * 8 for i in range(ndim)]
x = random_tensor(ndim, *dims)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,15 @@ def get_fake_program_more_detail(oneflow, mode, func, args=None, kwargs=None):
print("\n\n")


# NOTE(lixiang): When the graph global test is executed, the func is used to get the device type.
# There is no oneflow_kwargs["device"] case for graph global test.
def get_global_test_device(oneflow_args):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

突然想到这里 oneflow_args[0] 有不是一个 tensor 的情况,可能是个 int or float,后面我再修改下。
(不过不影响CI,因为global暂时没有打开graph的)
@strint @BBuf

if isinstance(oneflow_args[0], flow.Tensor):
return oneflow_args[0].placement.type
else:
return oneflow_args[0][0].placement.type


# NOTE(lixiang): When oneflow is of type nn.Module, build the following Graph for testing.
# graph_train_oneflow: is a deepcopy of oneflow.
def get_module_graph_test(graph_train_oneflow, oneflow, verbose, oneflow_args, *args):
Expand Down Expand Up @@ -382,6 +391,9 @@ def build(self):
elif oneflow.__name__ == "Parameter":
# nn.Graph donot deal with Parameter creation.
test_g_res = oneflow_res
# When doing the global op test, get_global_test_device() will be executed, and temporarily skipping the graph autotest on cpu device.
elif is_global() and (get_global_test_device(oneflow_args) == "cpu"):
test_g_res = oneflow_res
else:
test_g = TestGraphOfFunctional()
test_g_res = test_g()
Expand Down Expand Up @@ -422,8 +434,12 @@ def build(self):
return graph_tensor_oneflow(*tensor_graph_args, **tensor_graph_kwargs)

try:
test_g = TestGraphOfTensorMethod()
test_g_res = test_g()
# Set test_g_res = None, check_eager_graph_tensor will return True, the purpose is to temporarily skip the Graph global test on cpu.
if is_global() and (get_global_test_device((oneflow,)) == "cpu"):
test_g_res = None
else:
test_g = TestGraphOfTensorMethod()
test_g_res = test_g()
except Exception as e:
if not verbose:
get_fake_program_more_detail(
Expand Down Expand Up @@ -479,8 +495,12 @@ def oneflow_eager_run_with_graph_check(
test_g = get_module_graph_test(
graph_train_oneflow, oneflow, verbose, oneflow_args, *args
)
# When testing module methods, kwargs are not considered.
test_g_res = test_g(*graph_args)
# When doing the global op test, get_global_test_device() will be executed, and temporarily skipping the graph autotest on cpu device.
if is_global() and (get_global_test_device(oneflow_args) == "cpu"):
test_g_res = oneflow_res
else:
# When testing module methods, kwargs are not considered.
test_g_res = test_g(*graph_args)
elif oneflow.__name__ in ignore_apis_list:
find_check_module_func = False
# 1. "oneflow.nn.modules" not in oneflow.__module__: For avoid run nn.Module branch graph test, like fold op call Fold Module actually.
Expand Down