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

【prim】Matmul double grad composite api #50452

Merged

Conversation

xiaoguoguo626807
Copy link
Contributor

PR types

Others

PR changes

Others

Describe

matmul 二阶组合算子实现

@paddle-bot
Copy link

paddle-bot bot commented Feb 13, 2023

你的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.

@xiaoguoguo626807 xiaoguoguo626807 changed the base branch from matmul_double_grad to develop February 13, 2023 08:47
for (int64_t i = 0; i < axis_size; i++) {
if (axis[i] < 0) {
axis_[i] = axis[i] + x_dim_size;
std::cout << "axis_[" << i << "] = " << axis[i];
Copy link
Contributor

Choose a reason for hiding this comment

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

删掉打印相关的代码

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

desired=dx_,
rtol=TOLERANCE[d_type]['rtol'],
atol=TOLERANCE[d_type]['atol'],
)
Copy link
Contributor

Choose a reason for hiding this comment

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

请添加三阶测试保证拆解后反向的正确性

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

JiabinYang
JiabinYang previously approved these changes Feb 22, 2023
Copy link
Contributor

@JiabinYang JiabinYang left a comment

Choose a reason for hiding this comment

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

some coments

@@ -78,11 +81,38 @@ static phi::DDim get_reduce_dims(const phi::DDim& x_dims,
return get_reduce_dims_from_out(out_dims, x_dims);
}

static std::vector<int> get_reduce_dims(const Tensor& dx,
Copy link
Contributor

Choose a reason for hiding this comment

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

why this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when matmul used broadcast [1, 4, 3] * [2, 3, 4] =[2, 4, 4] ,x will be broadcast to [2, 4, 3] we need to compute the true dims [1, 4, 3] reduce dims will be [0]

@param.parameterized_class(
('primal0', 'primal1', 'primal2', 'trans_0', 'trans_1', 'dtype'),
[
# (
Copy link
Contributor

Choose a reason for hiding this comment

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

Add to do here to uncomment it when we fix static mode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -93,7 +93,7 @@ class StaticCompositeContext {
StaticCompositeContext()
: current_block_desc_(nullptr),
generator_(new UniqueNameGenerator()),
skip_comp_ops_({"matmul_v2"}) {}
skip_comp_ops_({"matmul_v2", "matmul_v2_grad"}) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

leave todo here to remove this when we fix static

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

JiabinYang
JiabinYang previously approved these changes Feb 27, 2023
Copy link
Contributor

@JiabinYang JiabinYang left a comment

Choose a reason for hiding this comment

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

LGTM

zhwesky2010
zhwesky2010 previously approved these changes Feb 27, 2023
Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

LGTM for run_unittests.sh

XiaoguangHu01
XiaoguangHu01 previously approved these changes Feb 27, 2023
Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@JiabinYang JiabinYang left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LGTM

@xiaoguoguo626807 xiaoguoguo626807 merged commit a0c473f into PaddlePaddle:develop Feb 28, 2023
@xiaoguoguo626807 xiaoguoguo626807 deleted the matmul_double_grad branch February 28, 2023 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants