未验证 提交 a0d59f9d 编写于 作者: J jiangcheng 提交者: GitHub

[CINN] add `paddle.framework.core.is_run_with_cinn()` api for running check (#54355)

* [CINN] add paddle.device.is_run_with_cinn() api for running check

* for pass ci converge

* add check whl should compiled with cinn

* fix ci coverage bug

* remove exposed API

* import is_run_with_cinn explicitly
上级 f3eded6c
......@@ -312,6 +312,15 @@ bool IsCompiledWithCINN() {
#endif
}
bool IsRunWithCINN() {
#ifndef PADDLE_WITH_CINN
return false;
#else
return framework::paddle2cinn::CinnCompiler::GetInstance()
->real_compiled_num() > 0;
#endif
}
bool IsCompiledWithHETERPS() {
#ifndef PADDLE_WITH_HETERPS
return false;
......@@ -1909,6 +1918,7 @@ All parameter, weight, gradient are variables in Paddle.
m.def("is_compiled_with_mpi", IsCompiledWithMPI);
m.def("is_compiled_with_mpi_aware", IsCompiledWithMPIAWARE);
m.def("is_compiled_with_cinn", IsCompiledWithCINN);
m.def("is_run_with_cinn", IsRunWithCINN);
m.def("_is_compiled_with_heterps", IsCompiledWithHETERPS);
m.def("supports_bfloat16", SupportsBfloat16);
m.def("supports_bfloat16_fast_performance", SupportsBfloat16FastPerformance);
......
......@@ -338,6 +338,10 @@ try:
from .libpaddle import _cleanup_mmap_fds
from .libpaddle import _remove_tensor_list_mmap_fds
from .libpaddle import _set_max_memory_map_allocation_pool_size
# CINN
from .libpaddle import is_run_with_cinn
except Exception as e:
if has_paddle_dy_lib:
sys.stderr.write(
......
......@@ -64,6 +64,18 @@ class TestCINN(unittest.TestCase):
sgd.clear_grad()
res.append(out.numpy())
if use_cinn and paddle.device.is_compiled_with_cinn():
self.assertTrue(
paddle.framework.core.is_run_with_cinn(),
msg="The test was not running with CINN! Please check.",
)
else:
self.assertFalse(
paddle.framework.core.is_run_with_cinn(),
msg="The test should not running with CINN when the whl package was not compiled with CINN! Please check.",
)
return res
def test_cinn(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册