|
|
|
@ -43,8 +43,9 @@ void VarDesc::SetTensorDescNum(size_t num) {
|
|
|
|
|
} break;
|
|
|
|
|
default:
|
|
|
|
|
PADDLE_THROW(
|
|
|
|
|
"Setting 'sub_tensor_number' is not supported by the type of var %s.",
|
|
|
|
|
this->Name());
|
|
|
|
|
platform::errors::Unavailable("Setting 'sub_tensor_number' is not "
|
|
|
|
|
"supported by the %s type variable.",
|
|
|
|
|
this->Name()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -55,8 +56,9 @@ size_t VarDesc::GetTensorDescNum() const {
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
PADDLE_THROW(
|
|
|
|
|
"Getting 'sub_tensor_number' is not supported by the type of var %s.",
|
|
|
|
|
this->Name());
|
|
|
|
|
platform::errors::Unavailable("Getting 'sub_tensor_number' is not "
|
|
|
|
|
"supported by the %s type variable.",
|
|
|
|
|
this->Name()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -133,9 +135,9 @@ void VarDesc::SetLoDLevel(int32_t lod_level) {
|
|
|
|
|
desc_.mutable_type()->mutable_tensor_array()->set_lod_level(lod_level);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
PADDLE_THROW(
|
|
|
|
|
"Setting 'lod_level' is not supported by the type of var %s.",
|
|
|
|
|
this->Name());
|
|
|
|
|
PADDLE_THROW(platform::errors::Unavailable(
|
|
|
|
|
"Setting 'lod_level' is not supported by the %s type variable.",
|
|
|
|
|
this->Name()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -157,9 +159,9 @@ void VarDesc::SetLoDLevels(const std::vector<int32_t> &multiple_lod_level) {
|
|
|
|
|
}
|
|
|
|
|
} break;
|
|
|
|
|
default:
|
|
|
|
|
PADDLE_THROW(
|
|
|
|
|
"Setting 'lod_levels' is not supported by the type of var %s.",
|
|
|
|
|
this->Name());
|
|
|
|
|
PADDLE_THROW(platform::errors::Unavailable(
|
|
|
|
|
"Setting 'lod_levels' is not supported by the %s type variable",
|
|
|
|
|
this->Name()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -170,9 +172,9 @@ int32_t VarDesc::GetLoDLevel() const {
|
|
|
|
|
case proto::VarType::LOD_TENSOR_ARRAY:
|
|
|
|
|
return desc_.type().tensor_array().lod_level();
|
|
|
|
|
default:
|
|
|
|
|
PADDLE_THROW(
|
|
|
|
|
"Getting 'lod_level' is not supported by the type of var %s.",
|
|
|
|
|
this->Name());
|
|
|
|
|
PADDLE_THROW(platform::errors::Unavailable(
|
|
|
|
|
"Getting 'lod_level' is not supported by the %s type variable.",
|
|
|
|
|
this->Name()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -187,15 +189,19 @@ std::vector<int32_t> VarDesc::GetLoDLevels() const {
|
|
|
|
|
return res;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
PADDLE_THROW(
|
|
|
|
|
"Getting 'lod_levels' is not supported by the type of var %s.",
|
|
|
|
|
this->Name());
|
|
|
|
|
PADDLE_THROW(platform::errors::Unavailable(
|
|
|
|
|
"Getting 'lod_levels' is not supported by the %s type variable.",
|
|
|
|
|
this->Name()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const proto::VarType::TensorDesc &VarDesc::tensor_desc() const {
|
|
|
|
|
PADDLE_ENFORCE(desc_.has_type(), "The var's type hasn't been set.");
|
|
|
|
|
PADDLE_ENFORCE(desc_.type().has_type(), "The var type hasn't been set.");
|
|
|
|
|
PADDLE_ENFORCE_EQ(
|
|
|
|
|
desc_.has_type(), true,
|
|
|
|
|
platform::errors::NotFound("The variable's type was not be set."));
|
|
|
|
|
PADDLE_ENFORCE_EQ(
|
|
|
|
|
desc_.type().has_type(), true,
|
|
|
|
|
platform::errors::NotFound("The variable's type was not be set."));
|
|
|
|
|
switch (desc_.type().type()) {
|
|
|
|
|
case proto::VarType::SELECTED_ROWS:
|
|
|
|
|
return desc_.type().selected_rows();
|
|
|
|
@ -204,14 +210,16 @@ const proto::VarType::TensorDesc &VarDesc::tensor_desc() const {
|
|
|
|
|
case proto::VarType::LOD_TENSOR_ARRAY:
|
|
|
|
|
return desc_.type().tensor_array().tensor();
|
|
|
|
|
default:
|
|
|
|
|
PADDLE_THROW(
|
|
|
|
|
"Getting 'tensor_desc' is not supported by the type of var %s.",
|
|
|
|
|
this->Name());
|
|
|
|
|
PADDLE_THROW(platform::errors::Unavailable(
|
|
|
|
|
"Getting 'tensor_desc' is not supported by the %s type variable.",
|
|
|
|
|
this->Name()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<proto::VarType::TensorDesc> VarDesc::tensor_descs() const {
|
|
|
|
|
PADDLE_ENFORCE(desc_.has_type(), "The var type hasn't been set.");
|
|
|
|
|
PADDLE_ENFORCE_EQ(
|
|
|
|
|
desc_.has_type(), true,
|
|
|
|
|
platform::errors::NotFound("The variable's type was not be set."));
|
|
|
|
|
std::vector<proto::VarType::TensorDesc> res;
|
|
|
|
|
res.reserve(GetTensorDescNum());
|
|
|
|
|
switch (desc_.type().type()) {
|
|
|
|
@ -221,16 +229,19 @@ std::vector<proto::VarType::TensorDesc> VarDesc::tensor_descs() const {
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
default:
|
|
|
|
|
PADDLE_THROW(
|
|
|
|
|
"Getting 'tensor_descs' is not supported by the type of var "
|
|
|
|
|
"%s.",
|
|
|
|
|
this->Name());
|
|
|
|
|
PADDLE_THROW(platform::errors::Unavailable(
|
|
|
|
|
"Getting 'tensor_descs' is not supported by the %s type variable.",
|
|
|
|
|
this->Name()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
proto::VarType::TensorDesc *VarDesc::mutable_tensor_desc() {
|
|
|
|
|
PADDLE_ENFORCE(desc_.has_type(), "The var type hasn't been set.");
|
|
|
|
|
PADDLE_ENFORCE(desc_.type().has_type(), "The var type hasn't been set.");
|
|
|
|
|
PADDLE_ENFORCE_EQ(
|
|
|
|
|
desc_.has_type(), true,
|
|
|
|
|
platform::errors::NotFound("The variable's type was not be set."));
|
|
|
|
|
PADDLE_ENFORCE_EQ(
|
|
|
|
|
desc_.type().has_type(), true,
|
|
|
|
|
platform::errors::NotFound("The variable's type was not be set."));
|
|
|
|
|
switch (desc_.type().type()) {
|
|
|
|
|
case proto::VarType::SELECTED_ROWS:
|
|
|
|
|
return desc_.mutable_type()->mutable_selected_rows();
|
|
|
|
@ -240,15 +251,19 @@ proto::VarType::TensorDesc *VarDesc::mutable_tensor_desc() {
|
|
|
|
|
return desc_.mutable_type()->mutable_tensor_array()->mutable_tensor();
|
|
|
|
|
default:
|
|
|
|
|
PADDLE_THROW(
|
|
|
|
|
"Getting 'mutable_tensor_desc' is not supported by the type of var "
|
|
|
|
|
"%s.",
|
|
|
|
|
this->Name());
|
|
|
|
|
platform::errors::Unavailable("Getting 'mutable_tensor_desc' is not "
|
|
|
|
|
"supported by the %s type variable.",
|
|
|
|
|
this->Name()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<proto::VarType::TensorDesc *> VarDesc::mutable_tensor_descs() {
|
|
|
|
|
PADDLE_ENFORCE(desc_.has_type(), "The var type hasn't been set.");
|
|
|
|
|
PADDLE_ENFORCE(desc_.type().has_type(), "The var type hasn't been set.");
|
|
|
|
|
PADDLE_ENFORCE_EQ(
|
|
|
|
|
desc_.has_type(), true,
|
|
|
|
|
platform::errors::NotFound("The variable's type was not be set."));
|
|
|
|
|
PADDLE_ENFORCE_EQ(
|
|
|
|
|
desc_.type().has_type(), true,
|
|
|
|
|
platform::errors::NotFound("The variable's type was not be set."));
|
|
|
|
|
std::vector<proto::VarType::TensorDesc *> res;
|
|
|
|
|
res.reserve(GetTensorDescNum());
|
|
|
|
|
switch (desc_.type().type()) {
|
|
|
|
@ -259,10 +274,9 @@ std::vector<proto::VarType::TensorDesc *> VarDesc::mutable_tensor_descs() {
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
default:
|
|
|
|
|
PADDLE_THROW(
|
|
|
|
|
"Getting 'tensor_descs' is not supported by the type of var "
|
|
|
|
|
"%s.",
|
|
|
|
|
this->Name());
|
|
|
|
|
PADDLE_THROW(platform::errors::Unavailable(
|
|
|
|
|
"Getting 'tensor_descs' is not supported by the %s type variable.",
|
|
|
|
|
this->Name()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|