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

add paddle.diag API, diag_v2 OP and CUDA kernel #26414

Merged
merged 2 commits into from
Aug 22, 2020

Conversation

LutaoChu
Copy link
Contributor

@LutaoChu LutaoChu commented Aug 18, 2020

PR types

New features

PR changes

OPs,APIs

Describe

支持如下功能:

  1. 如果输入是向量,构造对角矩阵;如果输入是矩阵,提取对角线元素,构造一维度向量
  2. 可设置对角线偏移量
  3. 可设置非对角线元素填充值

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@LutaoChu LutaoChu force-pushed the diag-op branch 2 times, most recently from 5318f3e to d1eda82 Compare August 19, 2020 11:20
@LutaoChu LutaoChu changed the title add paddle.tensor.linalg.diag API, diag_v2 OP and CUDA kernel add paddle.diag API, diag_v2 OP and CUDA kernel Aug 19, 2020
@LutaoChu LutaoChu force-pushed the diag-op branch 4 times, most recently from b3a5b98 to 967de62 Compare August 20, 2020 02:16
@@ -914,3 +913,92 @@ def meshgrid(*args, **kwargs):
type='meshgrid', inputs={'X': list(args)}, outputs={'Out': out})

return out


Copy link
Contributor

Choose a reason for hiding this comment

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

在旧的API加一下deprecated标注

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

@@ -914,3 +913,92 @@ def meshgrid(*args, **kwargs):
type='meshgrid', inputs={'X': list(args)}, outputs={'Out': out})

return out


def diag(x, offset=0, padding_value=0, name=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

在旧的API加一下deprecated标注

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

class TestDiagV2Op(OpTest):
def setUp(self):
self.op_type = "diag_v2"
self.x = np.random.rand(10, 10)
Copy link
Contributor

Choose a reason for hiding this comment

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

random.rand.seed 固定一下

set_padding_value(dev_ctx, out, static_cast<T>(padding_value));

auto x_length = x_dims[0];
const int x_stride = ComputeStride(0, x_dims);
Copy link
Contributor

Choose a reason for hiding this comment

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

如果是是使用const,建议使用const &

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

paddle/fluid/operators/diag_v2_op.cu Outdated Show resolved Hide resolved
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

@TCChenlong TCChenlong left a comment

Choose a reason for hiding this comment

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

LGTM

@wawltor wawltor merged commit 4e0c6d9 into PaddlePaddle:develop Aug 22, 2020
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.

4 participants