-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
【Hackathon 6th Fundable Projects 3 No.241】 [fluid_ops] straight_throu…
…gh_estimator_grad (#67299)
- Loading branch information
Showing
16 changed files
with
278 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
paddle/fluid/operators/ops_signature/moving_average_abs_max_scale_sig.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "paddle/phi/core/compat/op_utils.h" | ||
|
||
namespace phi { | ||
|
||
// we have to return every specific KernelSignature for inference now | ||
KernelSignature MovingAverageAbsMaxScaleOpArgumentMapping( | ||
const ArgumentMappingContext& ctx) { | ||
return KernelSignature("moving_average_abs_max_scale", | ||
{"X", "InAccum", "InState"}, | ||
{"moving_rate", "is_test"}, | ||
{"Out", "OutScale", "OutState", "OutAccum"}); | ||
} | ||
|
||
} // namespace phi | ||
|
||
PD_REGISTER_ARG_MAPPING_FN(moving_average_abs_max_scale, | ||
phi::MovingAverageAbsMaxScaleOpArgumentMapping); |
28 changes: 28 additions & 0 deletions
28
paddle/fluid/operators/ops_signature/straight_through_estimator_grad_sig.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "paddle/phi/core/compat/op_utils.h" | ||
|
||
namespace phi { | ||
|
||
KernelSignature StraightThroughEstimatorGradOpArgumentMapping( | ||
const ArgumentMappingContext& ctx) { | ||
return KernelSignature( | ||
"straight_through_estimator_grad", {"Out@GRAD"}, {}, {"X@GRAD"}); | ||
} | ||
|
||
} // namespace phi | ||
|
||
PD_REGISTER_ARG_MAPPING_FN(straight_through_estimator_grad, | ||
phi::StraightThroughEstimatorGradOpArgumentMapping); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
paddle/phi/kernels/cpu/moving_average_abs_max_scale_kernel.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "paddle/phi/core/kernel_registry.h" | ||
#include "paddle/phi/kernels/impl/moving_average_abs_max_scale_kernel_impl.h" | ||
|
||
PD_REGISTER_KERNEL(moving_average_abs_max_scale, | ||
CPU, | ||
ALL_LAYOUT, | ||
phi::MovingAverageAbsMaxScaleKernel, | ||
float) {} |
21 changes: 21 additions & 0 deletions
21
paddle/phi/kernels/cpu/straight_through_estimator_grad_kernel.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "paddle/phi/kernels/impl/straight_through_estimator_grad_kernel_impl.h" | ||
|
||
PD_REGISTER_KERNEL(straight_through_estimator_grad, | ||
CPU, | ||
ALL_LAYOUT, | ||
phi::StraightThroughEstimatorGradKernel, | ||
float) {} |
23 changes: 23 additions & 0 deletions
23
paddle/phi/kernels/gpu/moving_average_abs_max_scale_kernel.cu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "paddle/phi/core/kernel_registry.h" | ||
#include "paddle/phi/kernels/impl/moving_average_abs_max_scale_kernel_impl.h" | ||
|
||
PD_REGISTER_KERNEL(moving_average_abs_max_scale, | ||
GPU, | ||
ALL_LAYOUT, | ||
phi::MovingAverageAbsMaxScaleKernel, | ||
float, | ||
phi::dtype::float16) {} |
22 changes: 22 additions & 0 deletions
22
paddle/phi/kernels/gpu/straight_through_estimator_grad_kernel.cu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "paddle/phi/kernels/impl/straight_through_estimator_grad_kernel_impl.h" | ||
|
||
PD_REGISTER_KERNEL(straight_through_estimator_grad, | ||
GPU, | ||
ALL_LAYOUT, | ||
phi::StraightThroughEstimatorGradKernel, | ||
float, | ||
phi::dtype::float16) {} |
Oops, something went wrong.