Skip to content

Commit e3d2a66

Browse files
authored
【Hackathon 6th Fundable Projects 3 No.132】fetch_barrier (#65118)
* Fix * Fix * Fix * Fix * Fix
1 parent 31003a1 commit e3d2a66

File tree

8 files changed

+115
-81
lines changed

8 files changed

+115
-81
lines changed

paddle/fluid/operators/pscore/fetch_barrier_op.cc

Lines changed: 0 additions & 81 deletions
This file was deleted.

paddle/phi/infermeta/unary.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,11 @@ void FillAnyLikeInferMeta(const MetaTensor& x,
13921392
out->share_lod(x);
13931393
}
13941394

1395+
void FetchBarrierInferMeta(const std::vector<const MetaTensor*>& x,
1396+
int trainer_id,
1397+
const std::vector<std::string>& endpoints,
1398+
std::vector<MetaTensor*> out) {}
1399+
13951400
void FillDiagonalInferMeta(
13961401
const MetaTensor& x, float value, int offset, bool wrap, MetaTensor* out) {
13971402
PADDLE_ENFORCE_NE(

paddle/phi/infermeta/unary.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,11 @@ void FakeQuantizeAbsMaxInferMeta(const MetaTensor& x,
257257
MetaTensor* out,
258258
MetaTensor* out_scale);
259259

260+
void FetchBarrierInferMeta(const std::vector<const MetaTensor*>& x,
261+
int trainer_id,
262+
const std::vector<std::string>& endpoints,
263+
std::vector<MetaTensor*> out);
264+
260265
void FillAnyLikeInferMeta(const MetaTensor& x,
261266
const Scalar& value,
262267
DataType dtype,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "paddle/phi/backends/cpu/cpu_context.h"
16+
#include "paddle/phi/common/data_type.h"
17+
#include "paddle/phi/core/kernel_registry.h"
18+
#include "paddle/phi/kernels/impl/fetch_barrier_kernel_impl.h"
19+
20+
PD_REGISTER_KERNEL(fetch_barrier,
21+
CPU,
22+
ALL_LAYOUT,
23+
phi::FetchBarrierKernel,
24+
float,
25+
double,
26+
int,
27+
int64_t,
28+
phi::dtype::complex<float>,
29+
phi::dtype::complex<double>) {}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "paddle/phi/backends/gpu/gpu_context.h"
16+
#include "paddle/phi/common/data_type.h"
17+
#include "paddle/phi/core/kernel_registry.h"
18+
#include "paddle/phi/kernels/impl/fetch_barrier_kernel_impl.h"
19+
20+
PD_REGISTER_KERNEL(fetch_barrier,
21+
GPU,
22+
ALL_LAYOUT,
23+
phi::FetchBarrierKernel,
24+
float,
25+
double,
26+
int,
27+
int64_t,
28+
phi::dtype::float16,
29+
phi::dtype::complex<float>,
30+
phi::dtype::complex<double>) {}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#pragma once
16+
17+
#include "glog/logging.h"
18+
#include "paddle/phi/core/dense_tensor.h"
19+
#include "paddle/utils/optional.h"
20+
21+
namespace phi {
22+
template <typename T, typename Context>
23+
void FetchBarrierKernel(
24+
const Context &dev_ctx,
25+
const paddle::optional<std::vector<const DenseTensor *>> &x UNUSED,
26+
int trainer_id UNUSED,
27+
const std::vector<std::string> &endpoints UNUSED,
28+
std::vector<DenseTensor *> out UNUSED) {
29+
VLOG(5) << "FetchBarrier Sync, do not need now";
30+
}
31+
} // namespace phi

paddle/phi/ops/yaml/legacy/static_ops.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,15 @@
279279
param : [num_rows, num_columns, dtype]
280280
data_type : dtype
281281

282+
- op : fetch_barrier
283+
args: (Tensor[] x, int trainer_id = 0, str[] endpoints = {"127.0.0.1:6164"})
284+
output: Tensor[] (out){x.size()}
285+
infer_meta:
286+
func: FetchBarrierInferMeta
287+
kernel:
288+
func: fetch_barrier
289+
optional: x
290+
282291
- op : flatten2
283292
args: (Tensor x, int axis = 1)
284293
output: Tensor (out), Tensor (x_shape)

paddle/phi/ops/yaml/op_compat.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,12 @@
12381238
- op : feed
12391239
outputs: {out: Out}
12401240

1241+
- op : fetch_barrier
1242+
inputs:
1243+
x : X
1244+
outputs:
1245+
out : Out
1246+
12411247
- op : fft_c2c
12421248
inputs: {x: X}
12431249
outputs: {out: Out}

0 commit comments

Comments
 (0)