Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
zhwesky2010 committed Feb 23, 2022
1 parent 8f2a371 commit 7b8abf5
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 37 deletions.
31 changes: 5 additions & 26 deletions paddle/fluid/operators/poisson_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and
limitations under the License. */

#include <string>

#include "paddle/fluid/operators/poisson_op.h"
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/phi/core/infermeta_utils.h"
#include "paddle/phi/infermeta/unary.h"

namespace paddle {
namespace operators {
Expand Down Expand Up @@ -53,29 +55,6 @@ class PoissonOpInferVarType : public framework::PassInDtypeAndVarTypeToOutput {
}
};

template <typename T>
class PoissonKernel<platform::CPUDeviceContext, T>
: public framework::OpKernel<T> {
public:
void Compute(const framework::ExecutionContext &ctx) const override {
const auto *x = ctx.Input<framework::Tensor>("X");
auto *out = ctx.Output<framework::Tensor>("Out");

const T *x_data = x->data<T>();
T *out_data = out->mutable_data<T>(ctx.GetPlace());

int64_t size = x->numel();

auto gen = framework::DefaultCPUGenerator();
auto engine = gen->GetCPUEngine();

for (int64_t i = 0; i < size; ++i) {
std::poisson_distribution<> dist(x_data[i]);
out_data[i] = static_cast<T>(dist(*engine));
}
}
};

class PoissonGradOp : public framework::OperatorWithKernel {
public:
using framework::OperatorWithKernel::OperatorWithKernel;
Expand Down Expand Up @@ -109,7 +88,7 @@ namespace ops = paddle::operators;
namespace plat = paddle::platform;

DELCARE_INFER_SHAPE_FUNCTOR(poisson, PoissonInferShapeFunctor,
PT_INFER_META(phi::PoissonInferMeta));
PT_INFER_META(phi::UnchangedInferMeta));

REGISTER_OPERATOR(poisson, ops::PoissonOp, ops::PoissonOpMaker,
ops::PoissonOpInferVarType,
Expand Down
4 changes: 0 additions & 4 deletions paddle/phi/infermeta/unary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,6 @@ void TraceInferMeta(
out->set_dims(phi::make_ddim(sizes));
}

void PoissonInferMeta(const MetaTensor& x, MetaTensor* out) {
out->set_dims(x.dims());
}

void UnfoldInferMeta(const MetaTensor& x,
const std::vector<int>& kernel_sizes,
const std::vector<int>& strides,
Expand Down
2 changes: 0 additions & 2 deletions paddle/phi/infermeta/unary.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ void SplitInferMeta(const MetaTensor& x_meta,
void TraceInferMeta(
const MetaTensor& x, int offset, int axis1, int axis2, MetaTensor* out);

void PoissonInferMeta(const MetaTensor& x, MetaTensor* out);

void UnfoldInferMeta(const MetaTensor& x,
const std::vector<int>& kernel_sizes,
const std::vector<int>& strides,
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/cpu/poisson_grad_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/poisson_grad_kernel_impl.h"

PT_REGISTER_KERNEL(
PD_REGISTER_KERNEL(
poisson_grad, CPU, ALL_LAYOUT, phi::PoissonGradKernel, float, double) {}
2 changes: 1 addition & 1 deletion paddle/phi/kernels/cpu/poisson_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ void PoissonKernel(const Context& ctx, const DenseTensor& x, DenseTensor* out) {

} // namespace phi

PT_REGISTER_KERNEL(
PD_REGISTER_KERNEL(
poisson, CPU, ALL_LAYOUT, phi::PoissonKernel, float, double) {}
2 changes: 1 addition & 1 deletion paddle/phi/kernels/gpu/poisson_grad_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/poisson_grad_kernel_impl.h"

PT_REGISTER_KERNEL(
PD_REGISTER_KERNEL(
poisson_grad, GPU, ALL_LAYOUT, phi::PoissonGradKernel, float, double) {}
2 changes: 1 addition & 1 deletion paddle/phi/kernels/gpu/poisson_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ void PoissonKernel(const Context& ctx, const DenseTensor& x, DenseTensor* out) {

} // namespace phi

PT_REGISTER_KERNEL(
PD_REGISTER_KERNEL(
poisson, GPU, ALL_LAYOUT, phi::PoissonKernel, float, double) {}
2 changes: 1 addition & 1 deletion paddle/phi/ops/compat/poisson_sig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ KernelSignature PoissonGradOpArgumentMapping(

} // namespace phi

PT_REGISTER_ARG_MAPPING_FN(poisson_grad, phi::PoissonGradOpArgumentMapping);
PD_REGISTER_ARG_MAPPING_FN(poisson_grad, phi::PoissonGradOpArgumentMapping);

0 comments on commit 7b8abf5

Please sign in to comment.