Skip to content

Commit c923e6c

Browse files
chenwhqlYuanRishengSilv3S
authored
Adapting device-specific Extra Attributes for the PHI kernel (PaddlePaddle#46342)
* add extra attr property set * add type_info for all context * add onednn context to all context * fix context compile error * simplify conv kernel args * pass runtime attr into dev_ctx * fix marco error * clear conv_grad_kernel extra args * merge conv_grad_grad into conv_grad * clear conv2d_grad_grad extra attrs * clear yaml and eager extra attr * fix conv1d error * change to thread local * fix npu compile failed * try to fix windows compile failed * add conv2d onednn phi kernel * fix ci bugs (#36) * fix compile bugs (#38) * fix extra input transform bug (#39) * support dynamic created attr (#40) * reset extra info gen code * rm conv_grad_grad kernel * reimpl pass attr adapting * add int attr support * remove vector inputnames creating * fix map at error * Update paddle/phi/kernels/onednn/conv_grad_kernel.cc Co-authored-by: Sławomir Siwek <[email protected]> * remove useless extra attrs * replace mkldnn_engine by onednn_engine Co-authored-by: YuanRisheng <[email protected]> Co-authored-by: Sławomir Siwek <[email protected]>
1 parent f82d7e3 commit c923e6c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3673
-1955
lines changed

paddle/fluid/eager/api/manual/eager_manual/dygraph_forward_api.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ paddle::experimental::Tensor conv2d_ad_func(
2424
const paddle::experimental::Tensor& filter,
2525
std::vector<int> strides,
2626
std::vector<int> paddings,
27-
std::string paddding_algorithm,
28-
int groups,
27+
std::string padding_algorithm,
2928
std::vector<int> dilations,
30-
std::string data_format,
31-
bool use_addto,
32-
int workspace_size_MB,
33-
bool exhaustive_search);
29+
int groups,
30+
std::string data_format);

paddle/fluid/eager/api/manual/eager_manual/forwards/conv2d_fwd_function.cc

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,10 @@ paddle::experimental::Tensor conv2d_ad_func(
2929
const paddle::experimental::Tensor& filter,
3030
std::vector<int> strides,
3131
std::vector<int> paddings,
32-
std::string paddding_algorithm,
33-
int groups,
32+
std::string padding_algorithm,
3433
std::vector<int> dilations,
35-
std::string data_format,
36-
bool use_addto,
37-
int workspace_size_MB,
38-
bool exhaustive_search) {
34+
int groups,
35+
std::string data_format) {
3936
// Dygraph Record Event
4037
paddle::platform::RecordEvent dygraph_entrance_record_event(
4138
"conv2d dygraph", paddle::platform::TracerEventType::Operator, 1);
@@ -64,13 +61,10 @@ paddle::experimental::Tensor conv2d_ad_func(
6461
new_filter,
6562
strides,
6663
paddings,
67-
paddding_algorithm,
68-
groups,
64+
padding_algorithm,
6965
dilations,
70-
data_format,
71-
use_addto,
72-
workspace_size_MB,
73-
exhaustive_search);
66+
groups,
67+
data_format);
7468
}
7569
}
7670

@@ -92,13 +86,10 @@ paddle::experimental::Tensor conv2d_ad_func(
9286
filter,
9387
strides,
9488
paddings,
95-
paddding_algorithm,
96-
groups,
89+
padding_algorithm,
9790
dilations,
98-
data_format,
99-
use_addto,
100-
workspace_size_MB,
101-
exhaustive_search);
91+
groups,
92+
data_format);
10293
transformer->SetOutTensorLayout(&out);
10394
if (need_tune) {
10495
egr::Controller::Instance().EnableLayoutAutoTune();
@@ -119,13 +110,10 @@ paddle::experimental::Tensor conv2d_ad_func(
119110
filter,
120111
strides,
121112
paddings,
122-
paddding_algorithm,
123-
groups,
113+
padding_algorithm,
124114
dilations,
125-
data_format,
126-
use_addto,
127-
workspace_size_MB,
128-
exhaustive_search);
115+
groups,
116+
data_format);
129117
// Check NaN and Inf if needed
130118
if (FLAGS_check_nan_inf) {
131119
egr::CheckTensorHasNanOrInf("conv2d", api_result);
@@ -157,13 +145,10 @@ paddle::experimental::Tensor conv2d_ad_func(
157145
// SetAttributes if needed
158146
grad_node->SetAttributestrides(strides);
159147
grad_node->SetAttributepaddings(paddings);
160-
grad_node->SetAttributepaddding_algorithm(paddding_algorithm);
148+
grad_node->SetAttributepadding_algorithm(padding_algorithm);
161149
grad_node->SetAttributegroups(groups);
162150
grad_node->SetAttributedilations(dilations);
163151
grad_node->SetAttributedata_format(data_format);
164-
grad_node->SetAttributeuse_addto(use_addto);
165-
grad_node->SetAttributeworkspace_size_MB(workspace_size_MB);
166-
grad_node->SetAttributeexhaustive_search(exhaustive_search);
167152
// Set TensorWrappers for Forward Inputs if needed
168153
grad_node->SetTensorWrapperinput(input);
169154
grad_node->SetTensorWrapperfilter(filter);

paddle/fluid/eager/api/manual/eager_manual/nodes/conv2d_nodes.cc

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,10 @@ Conv2dGradNodeFinal::operator()(
4646
auto& grad_out = hooked_grads[0][0];
4747
auto& strides = this->strides_;
4848
auto& paddings = this->paddings_;
49-
auto& paddding_algorithm = this->paddding_algorithm_;
49+
auto& padding_algorithm = this->padding_algorithm_;
5050
auto& groups = this->groups_;
5151
auto& dilations = this->dilations_;
5252
auto& data_format = this->data_format_;
53-
auto& use_addto = this->use_addto_;
54-
auto& workspace_size_MB = this->workspace_size_MB_;
55-
auto& exhaustive_search = this->exhaustive_search_;
5653
// Prepare Grad function call
5754

5855
const auto& out_metas = OutputMeta();
@@ -87,13 +84,10 @@ Conv2dGradNodeFinal::operator()(
8784
grad_out,
8885
strides,
8986
paddings,
90-
paddding_algorithm,
91-
groups,
87+
padding_algorithm,
9288
dilations,
89+
groups,
9390
data_format,
94-
use_addto,
95-
workspace_size_MB,
96-
exhaustive_search,
9791
api_output_0,
9892
api_output_1);
9993
// Check NaN and Inf id needed
@@ -134,13 +128,10 @@ Conv2dGradNodeFinal::operator()(
134128
// SetAttributes if needed
135129
grad_node->SetAttributestrides(strides);
136130
grad_node->SetAttributepaddings(paddings);
137-
grad_node->SetAttributepaddding_algorithm(paddding_algorithm);
131+
grad_node->SetAttributepadding_algorithm(padding_algorithm);
138132
grad_node->SetAttributegroups(groups);
139133
grad_node->SetAttributedilations(dilations);
140134
grad_node->SetAttributedata_format(data_format);
141-
grad_node->SetAttributeuse_addto(use_addto);
142-
grad_node->SetAttributeworkspace_size_MB(workspace_size_MB);
143-
grad_node->SetAttributeexhaustive_search(exhaustive_search);
144135
// Set TensorWrappers for Forward Inputs if needed
145136
grad_node->SetTensorWrapperinput(input);
146137
grad_node->SetTensorWrapperfilter(filter);
@@ -215,13 +206,10 @@ Conv2dDoubleGradNodeFinal::operator()(
215206

216207
auto& strides = this->strides_;
217208
auto& paddings = this->paddings_;
218-
auto& paddding_algorithm = this->paddding_algorithm_;
209+
auto& padding_algorithm = this->padding_algorithm_;
219210
auto& groups = this->groups_;
220211
auto& dilations = this->dilations_;
221212
auto& data_format = this->data_format_;
222-
auto& use_addto = this->use_addto_;
223-
auto& workspace_size_MB = this->workspace_size_MB_;
224-
auto& exhaustive_search = this->exhaustive_search_;
225213
// Prepare Grad function call
226214

227215
const auto& out_metas = OutputMeta();
@@ -261,13 +249,10 @@ Conv2dDoubleGradNodeFinal::operator()(
261249
grad_filter_grad_optional,
262250
strides,
263251
paddings,
264-
paddding_algorithm,
265-
groups,
252+
padding_algorithm,
266253
dilations,
254+
groups,
267255
data_format,
268-
use_addto,
269-
workspace_size_MB,
270-
exhaustive_search,
271256
api_output_0,
272257
api_output_1,
273258
api_output_2);

paddle/fluid/eager/api/manual/eager_manual/nodes/nodes.h

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ class Conv2dGradNodeFinal : public egr::GradNodeBase {
6363
void SetAttributepaddings(const std::vector<int>& paddings) {
6464
paddings_ = paddings;
6565
}
66-
void SetAttributepaddding_algorithm(const std::string& paddding_algorithm) {
67-
paddding_algorithm_ = paddding_algorithm;
66+
void SetAttributepadding_algorithm(const std::string& padding_algorithm) {
67+
padding_algorithm_ = padding_algorithm;
6868
}
6969
void SetAttributegroups(const int& groups) { groups_ = groups; }
7070
void SetAttributedilations(const std::vector<int>& dilations) {
@@ -73,13 +73,6 @@ class Conv2dGradNodeFinal : public egr::GradNodeBase {
7373
void SetAttributedata_format(const std::string& data_format) {
7474
data_format_ = data_format;
7575
}
76-
void SetAttributeuse_addto(const bool& use_addto) { use_addto_ = use_addto; }
77-
void SetAttributeworkspace_size_MB(const int& workspace_size_MB) {
78-
workspace_size_MB_ = workspace_size_MB;
79-
}
80-
void SetAttributeexhaustive_search(const bool& exhaustive_search) {
81-
exhaustive_search_ = exhaustive_search;
82-
}
8376

8477
private:
8578
// TensorWrappers
@@ -89,13 +82,10 @@ class Conv2dGradNodeFinal : public egr::GradNodeBase {
8982
// Attributes
9083
std::vector<int> strides_;
9184
std::vector<int> paddings_;
92-
std::string paddding_algorithm_;
85+
std::string padding_algorithm_;
9386
int groups_;
9487
std::vector<int> dilations_;
9588
std::string data_format_;
96-
bool use_addto_;
97-
int workspace_size_MB_;
98-
bool exhaustive_search_;
9989
};
10090

10191
class Conv2dDoubleGradNodeFinal : public egr::GradNodeBase {
@@ -146,8 +136,8 @@ class Conv2dDoubleGradNodeFinal : public egr::GradNodeBase {
146136
void SetAttributepaddings(const std::vector<int>& paddings) {
147137
paddings_ = paddings;
148138
}
149-
void SetAttributepaddding_algorithm(const std::string& paddding_algorithm) {
150-
paddding_algorithm_ = paddding_algorithm;
139+
void SetAttributepadding_algorithm(const std::string& padding_algorithm) {
140+
padding_algorithm_ = padding_algorithm;
151141
}
152142
void SetAttributegroups(const int& groups) { groups_ = groups; }
153143
void SetAttributedilations(const std::vector<int>& dilations) {
@@ -156,13 +146,6 @@ class Conv2dDoubleGradNodeFinal : public egr::GradNodeBase {
156146
void SetAttributedata_format(const std::string& data_format) {
157147
data_format_ = data_format;
158148
}
159-
void SetAttributeuse_addto(const bool& use_addto) { use_addto_ = use_addto; }
160-
void SetAttributeworkspace_size_MB(const int& workspace_size_MB) {
161-
workspace_size_MB_ = workspace_size_MB;
162-
}
163-
void SetAttributeexhaustive_search(const bool& exhaustive_search) {
164-
exhaustive_search_ = exhaustive_search;
165-
}
166149

167150
private:
168151
// TensorWrappers
@@ -173,13 +156,10 @@ class Conv2dDoubleGradNodeFinal : public egr::GradNodeBase {
173156
// Attributes
174157
std::vector<int> strides_;
175158
std::vector<int> paddings_;
176-
std::string paddding_algorithm_;
159+
std::string padding_algorithm_;
177160
int groups_;
178161
std::vector<int> dilations_;
179162
std::string data_format_;
180-
bool use_addto_;
181-
int workspace_size_MB_;
182-
bool exhaustive_search_;
183163
};
184164

185165
class AddNGradNodeFinal : public egr::GradNodeBase {

paddle/fluid/framework/archive.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
#include <valarray>
3333
#include <vector>
3434

35-
#include "paddle/fluid/framework/expect.h"
3635
#include "paddle/fluid/platform/enforce.h"
36+
#include "paddle/phi/core/expect.h"
3737

3838
namespace paddle {
3939
namespace framework {

paddle/fluid/framework/channel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include <utility>
3131
#include <vector>
3232

33-
#include "paddle/fluid/framework/expect.h"
33+
#include "paddle/phi/core/expect.h"
3434

3535
namespace paddle {
3636
namespace framework {

0 commit comments

Comments
 (0)