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

[CINN] Add infer_symbol_shape for some ops #68166

Merged
merged 3 commits into from
Sep 23, 2024

Conversation

GoldenStain
Copy link
Contributor

@GoldenStain GoldenStain commented Sep 11, 2024

PR Category

CINN

PR Types

Improvements

Description

添加log_loss算子符号推导实现,按照字母序对原先的所有函数声明重新排序

Copy link

paddle-bot bot commented Sep 11, 2024

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Sep 11, 2024
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Sep 12, 2024
Comment on lines 1956 to 1958
const symbol::ShapeOrDataDimExprs &input_shape =
infer_context->GetShapeOrDataForValue(op->operand_source(0));
const symbol::ShapeOrDataDimExprs &label_shape =
infer_context->GetShapeOrDataForValue(op->operand_source(1));
Copy link
Contributor

Choose a reason for hiding this comment

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

推荐命名input_shape_or_data, 符号推导里有shape和data区的设计,一般在取shape时才使用 _shape 后缀

Comment on lines 1962 to 1969
PADDLE_ENFORCE_EQ(
input_shape.shape()[0],
label_shape.shape()[0],
common::errors::InvalidArgument(
"ShapeError: The batch_size of input and label must be the same. "
"But received input batch_size = %d, label batch_size = %d",
input_shape.shape()[0],
label_shape.shape()[0]));
Copy link
Contributor

Choose a reason for hiding this comment

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

dim 之间的约束应该使用 Addequalcstr()


// 二分类任务,label 通常是一维的(batch_size, 1),确保 input 的最后一维与
// label 的最后一维相同
if (input_shape.shape().size() == 2 && label_shape.shape().size() == 2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

PADDLE_ENFORCE_EQ 强制约束 input 和 label 的shape区数据size() == 2。然后写个for循环把两个dim都加上equalcstr

@GoldenStain
Copy link
Contributor Author

CI时身份信息验证失败,无法通过ci

@GoldenStain
Copy link
Contributor Author

PR-CE-Framework单测的paddle-infer项目,日志显示
2024-09-17 21:25:38 + exit 0
2024-09-17 21:25:38 {build code state=0}
2024-09-17 21:25:38 build paddle success!
但最终结果显示未通过;
PR-CI-Mac-Python3如下测试未通过:
2024-09-17 20:33:03 the following tests failed:
2024-09-17 20:33:03 + echo '
2024-09-17 20:33:03 371 - test_high_order_derivative (failed)
2024-09-17 20:33:03 563 - test_distribution_continuous_bernoulli (failed)
2024-09-17 20:33:03 760 - test_callback_wandb (failed)
2024-09-17 20:33:03 1504 - test_transforms_static (failed)
2024-09-17 20:33:03 test project /home/paddle/build
2024-09-17 20:33:03 807 - test_callback_wandb (failed)
2024-09-17 20:33:03 807 - test_callback_wandb (failed)'
2024-09-17 20:33:03 + sort -u
2024-09-17 20:33:03 + grep -e test_callback_wandb
2024-09-17 20:33:03 760 - test_callback_wandb (failed)
2024-09-17 20:33:03 807 - test_callback_wandb (failed)
但是不涉及我修改的LogLoss

infer_context->AddEqualCstr(input_shape_or_data.shape()[i],
label_shape_or_data.shape()[i]);
}

Copy link
Contributor

@gongshaotian gongshaotian Sep 18, 2024

Choose a reason for hiding this comment

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

麻烦补充一个equalcstr(input_shape[1], dimexpr(1)); 的约束,对于动态维度,能添加约束信息就尽量添加

label_shape_or_data.shape()[i]);
}

std::vector<symbol::DimExpr> output_shape = {symbol::DimExpr{1}};
Copy link
Contributor

Choose a reason for hiding this comment

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

这里是不是应该是 {input_shape[0], symbol::DimExpr{1}}

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@CLAassistant
Copy link

CLAassistant commented Sep 18, 2024

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@gongshaotian
Copy link
Contributor

image
看起来是有语法错误?

@GoldenStain
Copy link
Contributor Author

image 看起来是有语法错误?

不知道这个文件名是不是cmake或者make生成的,该目录下并没有这个文件;
我修改的函数返回值是bool值,我再检查一下

@GoldenStain
Copy link
Contributor Author

通过本地单测

@GoldenStain
Copy link
Contributor Author

GoldenStain commented Sep 21, 2024

PR-CI-Model-benchmark日志显示"fail; gpu_mem has increased, please contact RD for repair." 即便把paddle最新仓库原封不动提交跑PR也是这样;

@gongshaotian
Copy link
Contributor

PR-CI-Model-benchmark日志显示"fail; gpu_mem has increased, please contact RD for repair." 即便把paddle最新仓库原封不动提交跑PR也是这样;

目前已经通过,之前导致挂掉的问题负责同学已经修复

symbol::DimExpr one_dim = symbol::DimExpr{1};

infer_context->AddEqualCstr(input_shape[1], one_dim);
infer_context->AddEqualCstr(label_shape[1], one_dim);
Copy link
Contributor

Choose a reason for hiding this comment

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

这里其实添加一个就可以,上面已经添加了input_shape[1]和label_shape[1]的约束。可以放到下个pr修改

@gongshaotian
Copy link
Contributor

image
存在Optest 单测,check_pir flag已打开,test/legacy_test/test_log_loss_op.py

@gongshaotian
Copy link
Contributor

麻烦PR Title 中补充上log_loss op 信息

infer_context->GetShapeOrDataForValue(
op->operand_source(1));

const auto &input_shape = input_shape_or_data.shape();
Copy link
Contributor

Choose a reason for hiding this comment

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

这里可以直接写成
const auto &input_shape = infer_context->GetShapeOrDataForValue(op->operand_source(0)).shape();

Copy link
Contributor

Choose a reason for hiding this comment

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

这里可以直接写成
const auto &input_shape = infer_context->GetShapeOrDataForValue(op->operand_source(0)).shape();

@GoldenStain 下一个PR改一下哈

@luotao1 luotao1 merged commit f683edd into PaddlePaddle:develop Sep 23, 2024
28 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants