From c132c790111d7fadf212a72ec2cd35e03aed364f Mon Sep 17 00:00:00 2001 From: Xin Pan Date: Thu, 27 Dec 2018 11:23:24 +0800 Subject: [PATCH] address comments and resolve conflicts. test=develop --- paddle/fluid/imperative/layer.cc | 20 -------------------- paddle/fluid/imperative/layer.h | 3 +-- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/paddle/fluid/imperative/layer.cc b/paddle/fluid/imperative/layer.cc index 0d850ee162..26e7830265 100644 --- a/paddle/fluid/imperative/layer.cc +++ b/paddle/fluid/imperative/layer.cc @@ -100,26 +100,6 @@ class Autograd { } }; -void CreateVariable(const std::string& name, const framework::DDim& dim, - float val, bool random_name, framework::Variable* var) { - if (var->IsInitialized()) return; - - std::string varname = name; - if (random_name) { - std::mt19937 rng; - rng.seed(std::random_device()()); - std::uniform_int_distribution dist6( - 1, std::numeric_limits::max()); - int id = dist6(rng); - varname = string::Sprintf("%s@%d", varname, id); - } - - VLOG(3) << "creating var " << varname; - framework::LoDTensor* tensor = var->GetMutable(); - float* data = tensor->mutable_data(dim, platform::CPUPlace()); - std::fill(data, data + tensor->numel(), val); -} - framework::LoDTensor& VarBase::Grad() { VLOG(3) << "get var grad " << var_desc_->Name(); return *grads_->GetMutable(); diff --git a/paddle/fluid/imperative/layer.h b/paddle/fluid/imperative/layer.h index 6225edea77..ae4e8e0f8a 100644 --- a/paddle/fluid/imperative/layer.h +++ b/paddle/fluid/imperative/layer.h @@ -36,7 +36,6 @@ class PreparedOp { static PreparedOp Prepare(const framework::RuntimeContext& ctx, const framework::OperatorWithKernel& op, const platform::Place& place) { - framework::Scope dummy_scope; platform::DeviceContextPool& pool = platform::DeviceContextPool::Instance(); auto* dev_ctx = pool.Get(place); @@ -52,7 +51,7 @@ class PreparedOp { framework::OperatorWithKernel::OpKernelMap& kernels = kernels_iter->second; auto expected_kernel_key = op.GetExpectedKernelType( - framework::ExecutionContext(op, dummy_scope, *dev_ctx, ctx)); + framework::ExecutionContext(op, framework::Scope(), *dev_ctx, ctx)); VLOG(3) << "expected_kernel_key:" << expected_kernel_key; auto kernel_iter = kernels.find(expected_kernel_key); -- GitLab