Skip to content

Commit b2df4c7

Browse files
authored
remove .clang-format in paddle/fluid to use the same config (PaddlePaddle#43678)
1 parent f586110 commit b2df4c7

File tree

8 files changed

+30
-34
lines changed

8 files changed

+30
-34
lines changed

.clang-format

+2
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ Standard: Cpp11
2424
AllowAllParametersOfDeclarationOnNextLine: true
2525
BinPackParameters: false
2626
BinPackArguments: false
27+
IncludeBlocks: Preserve
28+
IncludeIsMainSourceRegex: (\.cu)$
2729
...

paddle/fluid/.clang-format

-5
This file was deleted.

paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.cc

+26-17
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License. */
1414

15-
// clang-format off
1615
#include "paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.h"
1716

1817
#include <algorithm>
@@ -31,7 +30,6 @@ limitations under the License. */
3130
#include "paddle/fluid/framework/convert_utils.h"
3231
#include "paddle/fluid/platform/enforce.h"
3332
#include "paddle/fluid/platform/errors.h"
34-
// clang-format on
3533

3634
namespace paddle {
3735
namespace framework {
@@ -79,7 +77,8 @@ FeedInfoMap CinnGraphSymbolization::GetFeedInfoMapFromInput() const {
7977
for (auto& feed_pair : input_tensors_) {
8078
const auto& feed_name = feed_pair.first;
8179
const auto* tensor = feed_pair.second;
82-
PADDLE_ENFORCE_NE(tensor, nullptr,
80+
PADDLE_ENFORCE_NE(tensor,
81+
nullptr,
8382
platform::errors::PreconditionNotMet(
8483
"The input variable %s's tensor cannot be NULL,"
8584
"we need the variable's dtype and shape from tensor.",
@@ -96,7 +95,8 @@ FeedInfoMap CinnGraphSymbolization::GetFeedInfoMapFromInput() const {
9695
}
9796

9897
PADDLE_ENFORCE_NE(
99-
feed_map[feed_name].shape.size(), 0UL,
98+
feed_map[feed_name].shape.size(),
99+
0UL,
100100
platform::errors::PreconditionNotMet(
101101
"The input variable %s's tensor shape cannot be empty,"
102102
"we need the variable's dtype and shape from tensor.",
@@ -136,7 +136,8 @@ CinnGraphSymbolization::CreateCinnScope(const FeedInfoMap& feed_map) {
136136

137137
for (const auto& param_name : parameter_names) {
138138
PADDLE_ENFORCE_GT(
139-
feed_map.count(param_name), 0UL,
139+
feed_map.count(param_name),
140+
0UL,
140141
platform::errors::NotFound("Cannot find parameter %s from input list,"
141142
"please add the tensor into input.",
142143
param_name.c_str()));
@@ -162,12 +163,12 @@ CinnGraphSymbolization::CreateCinnScope(const FeedInfoMap& feed_map) {
162163

163164
std::vector<Node*> CinnGraphSymbolization::TopologicalSort() const {
164165
std::unordered_set<Node*> op_nodes;
165-
std::for_each(graph_.Nodes().begin(), graph_.Nodes().end(),
166-
[&op_nodes](Node* n) {
167-
if (n->IsOp()) {
168-
op_nodes.emplace(n);
169-
}
170-
});
166+
std::for_each(
167+
graph_.Nodes().begin(), graph_.Nodes().end(), [&op_nodes](Node* n) {
168+
if (n->IsOp()) {
169+
op_nodes.emplace(n);
170+
}
171+
});
171172

172173
std::unordered_map<Node*, std::unordered_map<Node*, size_t>> adj_list;
173174
std::unordered_map<Node*, size_t> in_degrees;
@@ -210,7 +211,8 @@ std::vector<Node*> CinnGraphSymbolization::TopologicalSort() const {
210211
}
211212
}
212213

213-
PADDLE_ENFORCE_EQ(sorted_ops.size(), op_nodes.size(),
214+
PADDLE_ENFORCE_EQ(sorted_ops.size(),
215+
op_nodes.size(),
214216
platform::errors::PreconditionNotMet(
215217
"The sorting graph contains cycles."));
216218
return sorted_ops;
@@ -234,7 +236,8 @@ void CinnGraphSymbolization::RunOp(const CinnOpDesc& op_desc,
234236
const OpMapperContext& ctx) const {
235237
const auto& op_type = op_desc.Type();
236238
auto* kernel = ::cinn::frontend::OpMapperRegistry::Global()->Find(op_type);
237-
PADDLE_ENFORCE_NE(kernel, nullptr,
239+
PADDLE_ENFORCE_NE(kernel,
240+
nullptr,
238241
platform::errors::NotFound(
239242
"Op %s is Not Supported by CINN, please register"
240243
" this op in the CINN repo.",
@@ -256,10 +259,12 @@ std::unordered_set<std::string> CinnGraphSymbolization::GetFetchIds() const {
256259
std::unordered_set<std::string> fetch_names;
257260
fetch_names.reserve(fetch_var_names_.size());
258261
std::for_each(
259-
fetch_var_names_.begin(), fetch_var_names_.end(),
262+
fetch_var_names_.begin(),
263+
fetch_var_names_.end(),
260264
[this, &fetch_names](const std::string& name) {
261265
PADDLE_ENFORCE_EQ(
262-
var_model_to_program_map_.count(name), 1,
266+
var_model_to_program_map_.count(name),
267+
1,
263268
platform::errors::PreconditionNotMet(
264269
"Cannot find %s in var_model_to_program_map_", name.c_str()));
265270
fetch_names.insert(var_model_to_program_map_.at(name));
@@ -276,8 +281,12 @@ ::cinn::frontend::Program CinnGraphSymbolization::operator()() {
276281
auto feed_map = GetFeedInfoMapFromInput();
277282
auto cinn_scope = CreateCinnScope(feed_map);
278283

279-
OpMapperContext ctx(*cinn_scope, target_, &builder, &var_map_,
280-
&var_model_to_program_map_, &fetch_var_names_);
284+
OpMapperContext ctx(*cinn_scope,
285+
target_,
286+
&builder,
287+
&var_map_,
288+
&var_model_to_program_map_,
289+
&fetch_var_names_);
281290
// add all tensor's feed info into context
282291
for (auto& feed_pair : feed_map) {
283292
ctx.AddFeedInfo(feed_pair.first, feed_pair.second);

paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ limitations under the License. */
1414

1515
#pragma once
1616

17-
// clang-format off
1817
#include <map>
1918
#include <string>
2019
#include <unordered_map>
@@ -27,7 +26,6 @@ limitations under the License. */
2726

2827
#include "cinn/frontend/net_builder.h"
2928
#include "cinn/frontend/op_mapper_registry.h"
30-
// clang-format on
3129

3230
namespace paddle {
3331
namespace framework {
@@ -65,7 +63,8 @@ namespace paddle2cinn {
6563
class CinnGraphSymbolization {
6664
public:
6765
CinnGraphSymbolization(
68-
int64_t graph_id, const ir::Graph& graph,
66+
int64_t graph_id,
67+
const ir::Graph& graph,
6968
const ::cinn::common::Target& target,
7069
const std::map<std::string, const LoDTensor*>& input_tensors)
7170
: graph_id_(graph_id),

paddle/fluid/framework/paddle2cinn/transform_desc.h

-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
#pragma once
1616

17-
// The headers cant be sorted by clang-format or compilint error occurs.
18-
// clang-format off
1917
#include "paddle/fluid/framework/block_desc.h"
2018
#include "paddle/fluid/framework/op_desc.h"
2119
#include "paddle/fluid/framework/program_desc.h"
@@ -26,7 +24,6 @@
2624
#include "cinn/frontend/paddle/cpp/op_desc.h"
2725
#include "cinn/frontend/paddle/cpp/program_desc.h"
2826
#include "cinn/frontend/paddle/cpp/var_desc.h"
29-
// clang-format on
3027

3128
namespace paddle {
3229
namespace framework {

paddle/infrt/dialect/infrt/ir/infrt_dialect.cc

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
// clang-format off
1615
#include "paddle/infrt/dialect/infrt/ir/infrt_dialect.h"
1716

1817
#include <llvm/ADT/TypeSwitch.h>
@@ -61,7 +60,6 @@ void InfrtDialect::initialize() {
6160
#include "paddle/infrt/dialect/infrt/ir/test_kernels.cpp.inc"
6261
>();
6362
}
64-
// clang-format on
6563

6664
/// Parse a type registered to this dialect.
6765
mlir::Type InfrtDialect::parseType(::mlir::DialectAsmParser &parser) const {

paddle/infrt/tests/models/test_abs.cc

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
// clang-format off
1615
#include <gtest/gtest.h>
1716
#include <llvm/Support/CommandLine.h>
1817
#include <mlir/Pass/PassManager.h>
@@ -50,7 +49,6 @@
5049
#include "paddle/infrt/dialect/phi/ir/infrt_phi_tensor.h"
5150
#include "paddle/infrt/dialect/phi/ir/phi_base.h"
5251
#include "paddle/infrt/dialect/phi/ir/phi_kernels.h"
53-
// clang-format on
5452

5553
static llvm::cl::list<std::string> cl_shared_libs( // NOLINT
5654
"shared_libs",

paddle/phi/kernels/gpu/gelu_grad_kernel.cu

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
// clang-format off
1615
#include "paddle/phi/kernels/gelu_kernel.h"
1716

1817
#include "paddle/phi/backends/gpu/gpu_context.h"
@@ -21,7 +20,6 @@
2120
#include "paddle/phi/core/kernel_registry.h"
2221
#include "paddle/phi/kernels/funcs/broadcast_function.h"
2322
#include "paddle/phi/kernels/gpu/gelu_funcs.h"
24-
// clang-format on
2523

2624
DECLARE_bool(use_fast_math);
2725

0 commit comments

Comments
 (0)