#pragma once #include #include "glog/logging.h" #include "paddle/framework/eigen.h" #include "paddle/framework/operator.h" namespace paddle { namespace operators { template bool Gaussian( Generator g, T* output, const int size, const T& mean, const T& std); template class RandomOpKernel : public framework::OpKernel { public: void Compute(const framework::KernelContext& context) const override { auto mean = context.op_.attrs_.at("mean"); auto std = context.op_.attrs_.at("std"); auto seed = context.op_.attrs_.at("seed"); auto* output = context.Output(0)->GetMutable(); output->mutable_data(context.GetPlace()); Gaussian(, output, output->size(), mean, std) : // std::default_random_engine generator(seed); // std::normal_distribution distribution(mean, std); // framework::EigenMatrix::From(*output).device(*( // context.GetEigenDevice())) = // framework::EigenMatrix::Random(); } }; // using paddle::platform::CPUPlace; // template // class RandomOpKernel : public framework::OpKernel { // public: // void Compute(const framework::KernelContext& context) const override { // std::unique_ptr generator(seed); // for(size_t i=0; i < output->size(); ++i) { // output[i] = distribution(generator()); // } // } // }; // using paddle::platform::GPUPlace; // template // class RandomOpKernel : public framework::OpKernel { // public: // void Compute(const framework::KernelContext& context) const override { // } // } } // namespace operators } // namespace paddle