Skip to content

Commit a0b0a32

Browse files
authored
[Cherry-Pick]Add hard_swish/kron/linspace/logit/graph_send_recv/multi_dot/maxout/multiplex op yaml file (#41566)
* [Phi]Add graph_send_recv yaml file (#41206) * add graph_send_recv yaml * deal with confict * fix compile bugs * cherry-pick pr 41298 * cherry-pick pr41550 * fix compile bugs
1 parent 883d5be commit a0b0a32

File tree

21 files changed

+264
-48
lines changed

21 files changed

+264
-48
lines changed

paddle/fluid/operators/linspace_op.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class LinspaceOpMaker : public framework::OpProtoAndCheckerMaker {
6767

6868
namespace ops = paddle::operators;
6969
DECLARE_INFER_SHAPE_FUNCTOR(linspace, LinspaceInferShapeFunctor,
70-
PD_INFER_META(phi::LinspaceInferMeta));
70+
PD_INFER_META(phi::LinspaceRawInferMeta));
7171
REGISTER_OPERATOR(
7272
linspace, ops::LinspaceOp, ops::LinspaceOpMaker,
7373
paddle::framework::EmptyGradOpMaker<paddle::framework::OpDesc>,

paddle/phi/infermeta/ternary.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,10 @@ void LerpInferMeta(const MetaTensor& x,
276276
out->share_lod(x);
277277
}
278278

279-
void LinspaceInferMeta(const MetaTensor& start,
280-
const MetaTensor& stop,
281-
const MetaTensor& number,
282-
MetaTensor* out) {
279+
void LinspaceRawInferMeta(const MetaTensor& start,
280+
const MetaTensor& stop,
281+
const MetaTensor& number,
282+
MetaTensor* out) {
283283
auto s_dims = start.dims();
284284
PADDLE_ENFORCE_EQ(
285285
(s_dims.size() == 1) && (s_dims[0] == 1),
@@ -305,6 +305,14 @@ void LinspaceInferMeta(const MetaTensor& start,
305305
out->set_dtype(start.dtype());
306306
}
307307

308+
void LinspaceInferMeta(const MetaTensor& start,
309+
const MetaTensor& stop,
310+
const MetaTensor& number,
311+
DataType dtype,
312+
MetaTensor* out) {
313+
LinspaceRawInferMeta(start, stop, number, out);
314+
}
315+
308316
void NllLossRawInferMeta(const MetaTensor& input,
309317
const MetaTensor& label,
310318
paddle::optional<const MetaTensor&> weight,

paddle/phi/infermeta/ternary.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,15 @@ void LerpInferMeta(const MetaTensor& x,
6565
const MetaTensor& weight,
6666
MetaTensor* out);
6767

68+
void LinspaceRawInferMeta(const MetaTensor& start,
69+
const MetaTensor& stop,
70+
const MetaTensor& number,
71+
MetaTensor* out);
72+
6873
void LinspaceInferMeta(const MetaTensor& start,
6974
const MetaTensor& stop,
7075
const MetaTensor& number,
76+
DataType dtype,
7177
MetaTensor* out);
7278

7379
void NllLossRawInferMeta(const MetaTensor& input,

paddle/phi/kernels/activation_grad_kernel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ DECLARE_ACT_GRAD_KERNEL_WITH_ONE_ATTRS_DEPX(ThresholdedRelu, threshold);
197197
DECLARE_ACT_GRAD_KERNEL_WITH_ONE_ATTRS_DEPX(SoftShrink, lambda);
198198
DECLARE_ACT_GRAD_KERNEL_WITH_ONE_ATTRS_DEPX(HardShrink, threshold);
199199
DECLARE_ACT_GRAD_KERNEL_WITH_ONE_ATTRS_DEPX(Swish, beta);
200+
DECLARE_ACT_GRAD_KERNEL_WITH_ONE_ATTRS_DEPX(Logit, eps);
200201

201202
DECLARE_ACT_GRAD_KERNEL_WITH_TWO_ATTRS_DEPX(BRelu, t_min, t_max);
202203

paddle/phi/kernels/cpu/graph_send_recv_grad_kernel.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ void GraphSendRecvGradOpKernelLaunchHelper(
118118

119119
template <typename T, typename Context>
120120
void GraphSendRecvGradKernel(const Context& ctx,
121-
const DenseTensor& out_grad,
122121
const DenseTensor& x,
123-
paddle::optional<const DenseTensor&> out,
124122
const DenseTensor& src_index,
125123
const DenseTensor& dst_index,
124+
paddle::optional<const DenseTensor&> out,
126125
paddle::optional<const DenseTensor&> dst_count,
126+
const DenseTensor& out_grad,
127127
const std::string& pool_type,
128128
DenseTensor* x_grad) {
129129
auto index_type = src_index.dtype();

paddle/phi/kernels/gpu/graph_send_recv_grad_kernel.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ void GraphSendRecvGradOpCUDAKernelLaunchHelper(
102102

103103
template <typename T, typename Context>
104104
void GraphSendRecvGradKernel(const Context& ctx,
105-
const DenseTensor& out_grad,
106105
const DenseTensor& x,
107-
paddle::optional<const DenseTensor&> out,
108106
const DenseTensor& src_index,
109107
const DenseTensor& dst_index,
108+
paddle::optional<const DenseTensor&> out,
110109
paddle::optional<const DenseTensor&> dst_count,
110+
const DenseTensor& out_grad,
111111
const std::string& pool_type,
112112
DenseTensor* x_grad) {
113113
auto index_type = src_index.dtype();

paddle/phi/kernels/graph_send_recv_grad_kernel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ namespace phi {
2222

2323
template <typename T, typename Context>
2424
void GraphSendRecvGradKernel(const Context& ctx,
25-
const DenseTensor& out_grad,
2625
const DenseTensor& x,
27-
paddle::optional<const DenseTensor&> out,
2826
const DenseTensor& src_index,
2927
const DenseTensor& dst_index,
28+
paddle::optional<const DenseTensor&> out,
3029
paddle::optional<const DenseTensor&> dst_count,
30+
const DenseTensor& out_grad,
3131
const std::string& pool_type,
3232
DenseTensor* x_grad);
3333
} // namespace phi

paddle/phi/ops/compat/graph_send_recv_sig.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ KernelSignature GraphSendRecvGradOpArgumentMapping(
2828
const ArgumentMappingContext& ctx) {
2929
return KernelSignature(
3030
"graph_send_recv_grad",
31-
{GradVarName("Out"), "X", "Out", "Src_index", "Dst_index", "Dst_count"},
31+
{"X", "Src_index", "Dst_index", "Out", "Dst_count", GradVarName("Out")},
3232
{"pool_type"},
3333
{GradVarName("X")});
3434
}

python/paddle/fluid/dygraph/tracer.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
from paddle import _C_ops
2323

2424
final_state_name_mapping = {
25+
"graph_send_recv": {
26+
"final_op_name": "final_state_graph_send_recv",
27+
"x": "X",
28+
"src_index": "Src_index",
29+
"dst_index": "Dst_index",
30+
"out": "Out",
31+
"dst_count": "Dst_count"
32+
},
2533
"matmul_v2": {
2634
"final_op_name": "final_state_matmul",
2735
"transpose_x": "trans_x",

python/paddle/fluid/layers/tensor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,10 +1562,12 @@ def linspace(start, stop, num, dtype=None, name=None):
15621562
if not isinstance(num, Variable):
15631563
with device_guard("cpu"):
15641564
tensor_num = fill_constant([1], 'int32', num)
1565-
if _non_static_mode():
1565+
if _in_legacy_dygraph():
15661566
return _C_ops.linspace(tensor_start, tensor_stop, tensor_num, 'dtype',
15671567
dtype)
1568-
1568+
if in_dygraph_mode():
1569+
return _C_ops.final_state_linspace(tensor_start, tensor_stop,
1570+
tensor_num, dtype)
15691571
helper = LayerHelper("linspace", **locals())
15701572

15711573
start_dtype = convert_dtype(tensor_start.dtype)

0 commit comments

Comments
 (0)