Skip to content

Commit

Permalink
plt fix PaddleLT, test=model (#2966)
Browse files Browse the repository at this point in the history
* plt add ignore perf case, test=model

* plt add layer forward seed, test=model

* add saveload ci

* plt add allure desc, test=model

* revert plt

* plt fix PaddleLT, test=model

* plt fix PaddleLT, test=model

* plt fix PaddleLT, test=model

* plt fix PaddleLT, test=model

* plt fix PaddleLT, test=model

* plt fix PaddleLT, test=model

* plt update cinn recompute flags, test=model

* plt update cinn recompute flags, test=model
  • Loading branch information
Zeref996 authored Oct 11, 2024
1 parent 7d19455 commit 549e90e
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 41 deletions.
57 changes: 25 additions & 32 deletions framework/e2e/PaddleLT_new/PaddleLT.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,32 @@ def test_module_layer(title, layerfile, testing, device_place_id):
# allure.dynamic.feature(case)
allure.dynamic.feature("case")

# flags_str = ""
# for key, value in os.environ.items():
# if key.startswith("FLAGS_"):
# flags_str = flags_str + key + "=" + value + ";"
# flags_str += (
# "paddle_commit="
# + os.environ.get("paddle_commit")
# + ";"
# + "TESTING="
# + os.environ.get("TESTING")
# + ";"
# + "CUDA_VISIBLE_DEVICES="
# + os.environ.get("CUDA_VISIBLE_DEVICES")
# + ";"
# + "FRAMEWORK="
# + os.environ.get("FRAMEWORK")
# + ";"
# + "USE_PADDLE_MODEL="
# + os.environ.get("USE_PADDLE_MODEL")
# + ";"
# + "wheel_url="
# + os.environ.get("wheel_url")
# + ";"
# + "docker_image="
# + os.environ.get("docker_image")
# + ";"
# )
# for key, value in os.environ.items():
# if key.startswith("PLT_"):
# flags_str = flags_str + key + "=" + value + ";"
flags_str = ""
flags_str += f"pts_id={os.environ.get('pts_id', 'None')};"
flags_str += "\n"
flags_str += (
f"case_url=https://github.com/PaddlePaddle/PaddleTest/blob/develop/framework/e2e/PaddleLT_new/{layerfile}"
)
flags_str += "\n"
flags_str += f"paddle_commit={os.environ.get('paddle_commit', 'None')};"
flags_str += "\n"
flags_str += f"wheel_url={os.environ.get('wheel_url', 'None')};"
flags_str += "\n"
for key, value in os.environ.items():
if key.startswith("FLAGS_"):
flags_str = flags_str + key + "=" + value + ";"
flags_str += "\n"
flags_str += f"TESTING={os.environ.get('TESTING', 'None')};"
flags_str += f"CUDA_VISIBLE_DEVICES={os.environ.get('CUDA_VISIBLE_DEVICES', 'None')};"
flags_str += f"FRAMEWORK={os.environ.get('FRAMEWORK', 'None')};"
flags_str += f"USE_PADDLE_MODEL={os.environ.get('USE_PADDLE_MODEL', 'None')};"
flags_str += f"docker_image={os.environ.get('docker_image', 'None')};"
flags_str += "\n"
for key, value in os.environ.items():
if key.startswith("PLT_"):
flags_str = flags_str + key + "=" + value + ";"

# allure.dynamic.description(flags_str)
allure.dynamic.description("Layer Test")
allure.dynamic.description(flags_str)
single_test = layertest.LayerTest(
title=title, layerfile=layerfile, testing=testing, device_place_id=device_place_id
)
Expand Down
28 changes: 26 additions & 2 deletions framework/e2e/PaddleLT_new/engine/paddle_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def __init__(self, testing, layerfile, device_place_id, upstream_net):

self.use_multispec = os.environ.get("PLT_SPEC_USE_MULTI")

def _unset_flags(self, engine_str="test_engine"):
"""unset flags"""
if "FLAGS_cinn_auto_recompute" in os.environ:
del os.environ["FLAGS_cinn_auto_recompute"]
Logger(engine_str).get_log().info("已取消环境变量FLAGS_cinn_auto_recompute")

def _net_input(self):
"""get input"""
reset(self.seed)
Expand Down Expand Up @@ -135,6 +141,10 @@ def dy2st_eval_static_inputspec(self):

def dy2st_eval_cinn(self):
"""dy2st cinn eval"""

if os.environ.get("PLT_enable_auto_recompute", "0") == "1":
os.environ["FLAGS_cinn_auto_recompute"] = "1"
Logger("dy2st_eval_cinn").get_log().info("已设定环境变量FLAGS_cinn_auto_recompute")
data = self._net_input()
net = self._net_instant()

Expand All @@ -143,13 +153,19 @@ def dy2st_eval_cinn(self):
cinn_net = paddle.jit.to_static(net, build_strategy=build_strategy, full_graph=True)
cinn_net.eval()
logit = cinn_net(*data)

self._unset_flags(engine_str="dy2st_eval_cinn")
if self.return_net_instance == "True":
return {"res": {"logit": logit}, "net": cinn_net}
else:
return {"res": {"logit": logit}, "net": None}

def dy2st_eval_cinn_inputspec(self):
"""dy2st cinn eval with inputspec"""
"""dy2st cinn eval with dy inputspec"""

if os.environ.get("PLT_enable_auto_recompute", "0") == "1":
os.environ["FLAGS_cinn_auto_recompute"] = "1"
Logger("dy2st_eval_cinn_inputspec").get_log().info("已设定环境变量FLAGS_cinn_auto_recompute")
data, input_spec = self._net_input_and_spec()
Logger("dy2st_eval_cinn_inputspec").get_log().info(f"待测动态InputSpec为: {input_spec}")
net = self._net_instant()
Expand All @@ -159,13 +175,19 @@ def dy2st_eval_cinn_inputspec(self):
cinn_net = paddle.jit.to_static(net, build_strategy=build_strategy, full_graph=True, input_spec=input_spec)
cinn_net.eval()
logit = cinn_net(*data)

self._unset_flags(engine_str="dy2st_eval_cinn_inputspec")
if self.return_net_instance == "True":
return {"res": {"logit": logit}, "net": cinn_net}
else:
return {"res": {"logit": logit}, "net": None}

def dy2st_eval_cinn_static_inputspec(self):
"""dy2st cinn eval with inputspec"""
"""dy2st cinn eval with st inputspec"""

if os.environ.get("PLT_enable_auto_recompute", "0") == "1":
os.environ["FLAGS_cinn_auto_recompute"] = "1"
Logger("dy2st_eval_cinn_static_inputspec").get_log().info("已设定环境变量FLAGS_cinn_auto_recompute")
data, input_spec = self._net_input_and_static_spec()
Logger("dy2st_eval_cinn_static_inputspec").get_log().info(f"待测静态InputSpec为: {input_spec}")
net = self._net_instant()
Expand All @@ -175,6 +197,8 @@ def dy2st_eval_cinn_static_inputspec(self):
cinn_net = paddle.jit.to_static(net, build_strategy=build_strategy, full_graph=True, input_spec=input_spec)
cinn_net.eval()
logit = cinn_net(*data)

self._unset_flags(engine_str="dy2st_eval_cinn_static_inputspec")
if self.return_net_instance == "True":
return {"res": {"logit": logit}, "net": cinn_net}
else:
Expand Down
35 changes: 28 additions & 7 deletions framework/e2e/PaddleLT_new/engine/paddle_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ def __init__(self, testing, layerfile, device_place_id, upstream_net):
self.layerfile = layerfile
self.step = self.testing.get("step")

def _unset_flags(self, engine_str="test_engine"):
"""unset flags"""
if "FLAGS_cinn_auto_recompute" in os.environ:
del os.environ["FLAGS_cinn_auto_recompute"]
Logger(engine_str).get_log().info("已取消环境变量FLAGS_cinn_auto_recompute")

def _net_input(self):
"""get input"""
reset(self.seed)
Expand Down Expand Up @@ -240,7 +246,7 @@ def dy2st_train(self):
return {"res": {"logit": logit, "data_grad": data_grad}, "net": None}

def dy2st_train_inputspec(self):
"""dy2st cinn train with inputspec"""
"""dy2st train with dy inputspec"""
data, input_spec = self._net_input_and_spec()
Logger("dy2st_train_inputspec").get_log().info(f"待测动态InputSpec为: {input_spec}")
net = self._net_instant()
Expand Down Expand Up @@ -272,7 +278,7 @@ def dy2st_train_inputspec(self):
return {"res": {"logit": logit, "data_grad": data_grad}, "net": None}

def dy2st_train_static_inputspec(self):
"""dy2st cinn train with inputspec"""
"""dy2st train with st inputspec"""
data, input_spec = self._net_input_and_static_spec()
Logger("dy2st_train_static_inputspec").get_log().info(f"待测静态InputSpec为: {input_spec}")
net = self._net_instant()
Expand Down Expand Up @@ -305,6 +311,10 @@ def dy2st_train_static_inputspec(self):

def dy2st_train_cinn(self):
"""dy2st cinn train"""

if os.environ.get("PLT_enable_auto_recompute", "0") == "1":
os.environ["FLAGS_cinn_auto_recompute"] = "1"
Logger("dy2st_train_cinn").get_log().info("已设定环境变量FLAGS_cinn_auto_recompute")
data = self._net_input()
net = self._net_instant()
optimizer = self._net_optimizer()
Expand All @@ -330,14 +340,19 @@ def dy2st_train_cinn(self):

Logger("dy2st_train_cinn").get_log().info(f"已完成 {epoch} 轮训练")
data_grad = self._get_data_grad(data)
# return {"logit": logit, "data_grad": data_grad}

self._unset_flags(engine_str="dy2st_train_cinn")
if self.return_net_instance == "True":
return {"res": {"logit": logit, "data_grad": data_grad}, "net": cinn_net}
else:
return {"res": {"logit": logit, "data_grad": data_grad}, "net": None}

def dy2st_train_cinn_inputspec(self):
"""dy2st cinn train with inputspec"""
"""dy2st cinn train with dy inputspec"""

if os.environ.get("PLT_enable_auto_recompute", "0") == "1":
os.environ["FLAGS_cinn_auto_recompute"] = "1"
Logger("dy2st_train_cinn_inputspec").get_log().info("已设定环境变量FLAGS_cinn_auto_recompute")
data, input_spec = self._net_input_and_spec()
Logger("dy2st_train_cinn_inputspec").get_log().info(f"待测动态InputSpec为: {input_spec}")
net = self._net_instant()
Expand All @@ -364,14 +379,19 @@ def dy2st_train_cinn_inputspec(self):

Logger("dy2st_train_cinn_inputspec").get_log().info(f"已完成 {epoch} 轮训练")
data_grad = self._get_data_grad(data)
# return {"logit": logit, "data_grad": data_grad}

self._unset_flags(engine_str="dy2st_train_cinn_inputspec")
if self.return_net_instance == "True":
return {"res": {"logit": logit, "data_grad": data_grad}, "net": cinn_net}
else:
return {"res": {"logit": logit, "data_grad": data_grad}, "net": None}

def dy2st_train_cinn_static_inputspec(self):
"""dy2st cinn train with inputspec"""
"""dy2st cinn train with st inputspec"""

if os.environ.get("PLT_enable_auto_recompute", "0") == "1":
os.environ["FLAGS_cinn_auto_recompute"] = "1"
Logger("dy2st_train_cinn_static_inputspec").get_log().info("已设定环境变量FLAGS_cinn_auto_recompute")
data, input_spec = self._net_input_and_static_spec()
Logger("dy2st_train_cinn_static_inputspec").get_log().info(f"待测静态InputSpec为: {input_spec}")
net = self._net_instant()
Expand All @@ -398,7 +418,8 @@ def dy2st_train_cinn_static_inputspec(self):

Logger("dy2st_train_cinn_static_inputspec").get_log().info(f"已完成 {epoch} 轮训练")
data_grad = self._get_data_grad(data)
# return {"logit": logit, "data_grad": data_grad}

self._unset_flags(engine_str="dy2st_train_cinn_static_inputspec")
if self.return_net_instance == "True":
return {"res": {"logit": logit, "data_grad": data_grad}, "net": cinn_net}
else:
Expand Down

0 comments on commit 549e90e

Please sign in to comment.