#pragma once #include #include "glog/logging.h" #include "paddle/framework/eigen.h" #include "paddle/framework/operator.h" namespace paddle { namespace operators { template class RandomOpKernel : public framework::OpKernel { public: void Compute(const framework::KernelContext& context) const override { auto* output = context.Output(0)->GetMutable(); output->mutable_data(context.GetPlace()); auto shape = context.op_.attrs_.at("Shape"); auto mean = context.op_.attrs_.at("mean"); auto std = context.op_.attrs_.at("std"); auto seed = context.op_.attrs_.at("seed"); // std::default_random_engine generator(seed); // std::normal_distribution distribution(mean, std); framework::EigenMatrix::From(*output).device(*( context.GetEigenDevice())) = framework::EigenMatrix::Random(); } }; } // namespace operators } // namespace paddle