提交 70981f5d 编写于 作者: X Xin Pan

clean

test=develop
上级 fb8ae303
......@@ -143,14 +143,12 @@ RuntimeContext::RuntimeContext(const VariableNameMap& innames,
for (auto& var_name_item : innames) {
std::vector<Variable*>& input_vars = inputs[var_name_item.first];
for (auto& var_name : var_name_item.second) {
LOG(ERROR) << "first in " << var_name_item.first << ":" << var_name;
input_vars.push_back(scope.FindVar(var_name));
}
}
for (auto& var_name_item : outnames) {
std::vector<Variable*>& output_vars = outputs[var_name_item.first];
for (auto& var_name : var_name_item.second) {
LOG(ERROR) << "first out " << var_name_item.first << ":" << var_name;
output_vars.push_back(scope.FindVar(var_name));
}
}
......@@ -441,22 +439,13 @@ const Variable* ExecutionContext::InputVar(const std::string& name) const {
return it->second.empty() ? nullptr : it->second[0];
}
Variable* ExecutionContext::OutputVar(const std::string& name) const {
auto opt = op_.Output(name);
return opt == kEmptyVarName ? nullptr : scope_.FindVar(opt);
}
const Variable* ExecutionContext::FastInputVar(const std::string& name) const {
auto it = ctx_.inputs.find(name);
if (it == ctx_.inputs.end()) return nullptr;
PADDLE_ENFORCE_LE(it->second.size(), 1UL,
"Operator %s's input %s should contain only one variable.",
op_.Type(), name);
return it->second.empty() ? nullptr : it->second[0];
const Variable* ExecutionContext::LegacyInputVar(
const std::string& name) const {
auto ipt = op_.Input(name);
return ipt == kEmptyVarName ? nullptr : scope_.FindVar(ipt);
}
Variable* ExecutionContext::FastOutputVar(const std::string& name) const {
Variable* ExecutionContext::OutputVar(const std::string& name) const {
auto it = ctx_.outputs.find(name);
if (it == ctx_.outputs.end()) return nullptr;
......@@ -466,15 +455,20 @@ Variable* ExecutionContext::FastOutputVar(const std::string& name) const {
return it->second.empty() ? nullptr : it->second[0];
}
Variable* ExecutionContext::LegacyOutputVar(const std::string& name) const {
auto opt = op_.Output(name);
return opt == kEmptyVarName ? nullptr : scope_.FindVar(opt);
}
template <>
const Tensor* ExecutionContext::Input<Tensor>(const std::string& name) const {
return Input<LoDTensor>(name);
}
template <>
const Tensor* ExecutionContext::FastInput<Tensor>(
const Tensor* ExecutionContext::LegacyInput<Tensor>(
const std::string& name) const {
return FastInput<LoDTensor>(name);
return LegacyInput<LoDTensor>(name);
}
template <>
......@@ -502,8 +496,8 @@ Tensor* ExecutionContext::Output<Tensor>(const std::string& name) const {
}
template <>
Tensor* ExecutionContext::FastOutput<Tensor>(const std::string& name) const {
return FastOutput<LoDTensor>(name);
Tensor* ExecutionContext::LegacyOutput<Tensor>(const std::string& name) const {
return LegacyOutput<LoDTensor>(name);
}
template <>
......@@ -870,7 +864,6 @@ Scope* OperatorWithKernel::PrepareData(
auto& var_name = var_name_item.second[i];
auto* var = scope.FindVar(var_name);
input_vars[i] = var;
LOG(ERROR) << "second in " << var_name_item.first << ":" << var_name;
// Only tensor can be tranfer to another device.
if (var == nullptr || !VarIsTensor(*var)) {
......@@ -931,7 +924,6 @@ Scope* OperatorWithKernel::PrepareData(
for (size_t i = 0; i < var_name_item.second.size(); ++i) {
auto& var_name = var_name_item.second[i];
output_vars[i] = scope.FindVar(var_name);
LOG(ERROR) << "second out " << var_name_item.first << ":" << var_name;
}
}
......
......@@ -233,20 +233,20 @@ class ExecutionContext {
}
template <typename T>
const T* FastInput(const std::string& name) const {
auto* var = FastInputVar(name);
const T* LegacyInput(const std::string& name) const {
auto* var = LegacyInputVar(name);
return var == nullptr ? nullptr : &var->Get<T>();
}
template <typename T>
T* FastOutput(const std::string& name) const {
auto var = FastOutputVar(name);
T* LegacyOutput(const std::string& name) const {
auto var = LegacyOutputVar(name);
return var == nullptr ? nullptr : var->GetMutable<T>();
}
const Variable* FastInputVar(const std::string& name) const;
const Variable* LegacyInputVar(const std::string& name) const;
Variable* FastOutputVar(const std::string& name) const;
Variable* LegacyOutputVar(const std::string& name) const;
template <typename T>
const std::vector<const T*> MultiInput(const std::string& name) const {
......@@ -314,7 +314,7 @@ template <>
const Tensor* ExecutionContext::Input<Tensor>(const std::string& name) const;
template <>
const Tensor* ExecutionContext::FastInput<Tensor>(
const Tensor* ExecutionContext::LegacyInput<Tensor>(
const std::string& name) const;
template <>
......@@ -325,7 +325,7 @@ template <>
Tensor* ExecutionContext::Output<Tensor>(const std::string& name) const;
template <>
Tensor* ExecutionContext::FastOutput<Tensor>(const std::string& name) const;
Tensor* ExecutionContext::LegacyOutput<Tensor>(const std::string& name) const;
template <>
std::vector<Tensor*> ExecutionContext::MultiOutput<Tensor>(
......
......@@ -56,7 +56,7 @@ class PReluOp : public framework::OperatorWithKernel {
protected:
framework::OpKernelType GetExpectedKernelType(
const framework::ExecutionContext &ctx) const override {
return framework::OpKernelType(ctx.FastInput<Tensor>("X")->type(),
return framework::OpKernelType(ctx.Input<Tensor>("X")->type(),
ctx.device_context());
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册