update gpu code

revert-3824-remove_grad_op_type
qiaolongfei 8 years ago
parent 6fcdc91638
commit 848c317aa8

@ -43,13 +43,13 @@ class GPUGaussianRandomKernel : public framework::OpKernel {
auto* tensor = context.Output<framework::Tensor>("Out");
T* data = tensor->mutable_data<T>(context.GetPlace());
unsigned int seed =
static_cast<unsigned int>(context.op_.GetAttr<int>("seed"));
static_cast<unsigned int>(context.op().GetAttr<int>("seed"));
if (seed == 0) {
std::random_device rd;
seed = rd();
}
T mean = static_cast<T>(context.op_.GetAttr<float>("mean"));
T std = static_cast<T>(context.op_.GetAttr<float>("std"));
T mean = static_cast<T>(context.op().GetAttr<float>("mean"));
T std = static_cast<T>(context.op().GetAttr<float>("std"));
thrust::counting_iterator<unsigned int> index_sequence_begin(0);
ssize_t N = framework::product(tensor->dims());
thrust::transform(index_sequence_begin, index_sequence_begin + N,

@ -46,13 +46,13 @@ class GPUUniformRandomKernel : public framework::OpKernel {
auto* tensor = context.Output<framework::Tensor>("Out");
T* data = tensor->mutable_data<T>(context.GetPlace());
unsigned int seed =
static_cast<unsigned int>(context.op_.GetAttr<int>("seed"));
static_cast<unsigned int>(context.op().GetAttr<int>("seed"));
if (seed == 0) {
std::random_device rd;
seed = rd();
}
T min = static_cast<T>(context.op_.GetAttr<float>("min"));
T max = static_cast<T>(context.op_.GetAttr<float>("max"));
T min = static_cast<T>(context.op().GetAttr<float>("min"));
T max = static_cast<T>(context.op().GetAttr<float>("max"));
thrust::counting_iterator<unsigned int> index_sequence_begin(0);
ssize_t N = framework::product(tensor->dims());
thrust::transform(index_sequence_begin, index_sequence_begin + N,

Loading…
Cancel
Save