|
|
|
@ -18,10 +18,18 @@ limitations under the License. */
|
|
|
|
|
namespace paddle {
|
|
|
|
|
namespace framework {
|
|
|
|
|
|
|
|
|
|
framework::DDim InferShapeContext::GetInputDim(const std::string &name) const {
|
|
|
|
|
const std::vector<std::string> &arg_names = Inputs(name);
|
|
|
|
|
PADDLE_ENFORCE_EQ(arg_names.size(), 1UL,
|
|
|
|
|
"Input(%s) shoudl holds one element, but now it holds %d",
|
|
|
|
|
name, arg_names.size());
|
|
|
|
|
return this->GetDim(arg_names[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<framework::DDim> InferShapeContext::GetInputsDim(
|
|
|
|
|
const std::string &name) const {
|
|
|
|
|
const std::vector<std::string> &names = Inputs(name);
|
|
|
|
|
return GetDims(names);
|
|
|
|
|
const std::vector<std::string> &arg_names = Inputs(name);
|
|
|
|
|
return GetDims(arg_names);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DDim InferShapeContext::GetInputsElementDim(const std::string &name,
|
|
|
|
@ -30,13 +38,21 @@ DDim InferShapeContext::GetInputsElementDim(const std::string &name,
|
|
|
|
|
return this->GetDim(names[idx]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InferShapeContext::SetOutputDim(const std::string &name, const DDim &dim) {
|
|
|
|
|
auto &arg_names = Outputs(name);
|
|
|
|
|
PADDLE_ENFORCE_EQ(arg_names.size(), 1UL,
|
|
|
|
|
"Output(%s) shoudl holds one element, but now it holds %d",
|
|
|
|
|
name, arg_names.size());
|
|
|
|
|
SetDim(arg_names[0], dim);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InferShapeContext::SetOutputsDim(
|
|
|
|
|
const std::string &name, const std::vector<framework::DDim> &dims) {
|
|
|
|
|
auto &names = Outputs(name);
|
|
|
|
|
SetDims(names, dims);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<framework::DDim> InferShapeContext::GetDims(
|
|
|
|
|
std::vector<DDim> InferShapeContext::GetDims(
|
|
|
|
|
const std::vector<std::string> &names) const {
|
|
|
|
|
std::vector<framework::DDim> ret;
|
|
|
|
|
ret.reserve(names.size());
|
|
|
|
@ -45,7 +61,6 @@ std::vector<framework::DDim> InferShapeContext::GetDims(
|
|
|
|
|
[this](const std::string &name) { return this->GetDim(name); });
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InferShapeContext::SetDims(const std::vector<std::string> &names,
|
|
|
|
|
const std::vector<framework::DDim> &dims) {
|
|
|
|
|
size_t length = names.size();
|
|
|
|
|