Skip to content

Commit 959e3dd

Browse files
authored
Replace phi::errors [fluid_ops] part10 (#66649)
1 parent e75a6b6 commit 959e3dd

File tree

420 files changed

+2966
-2895
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

420 files changed

+2966
-2895
lines changed

paddle/fluid/framework/archive.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ArchiveBase {
4646
// Archive is not copyable. But to allow move capture by function objects,
4747
// check it at runtime rather than at compile time.
4848
ArchiveBase(const ArchiveBase&) {
49-
PADDLE_THROW(phi::errors::Unavailable(
49+
PADDLE_THROW(common::errors::Unavailable(
5050
"ArchiveBase class does not support copy construction."));
5151
}
5252

@@ -67,7 +67,7 @@ class ArchiveBase {
6767

6868
public:
6969
ArchiveBase& operator=(const ArchiveBase&) {
70-
PADDLE_THROW(phi::errors::Unavailable(
70+
PADDLE_THROW(common::errors::Unavailable(
7171
"ArchiveBase class does not support assignment construction."));
7272
return *this;
7373
}

paddle/fluid/framework/attribute.cc

+17-17
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ paddle::any GetAttrValue(const Attribute& attr) {
5959
case proto::AttrType::SCALARS:
6060
return PADDLE_GET_CONST(std::vector<paddle::experimental::Scalar>, attr);
6161
default:
62-
PADDLE_THROW(phi::errors::Unimplemented(
62+
PADDLE_THROW(common::errors::Unimplemented(
6363
"Unsupported Attribute value type `%s` for phi.",
6464
platform::demangle(attr.type().name())));
6565
}
@@ -142,8 +142,8 @@ Attribute GetAttrValue(const proto::OpDesc::Attr& attr_desc) {
142142
}
143143

144144
default:
145-
PADDLE_THROW(phi::errors::Unavailable("Unsupported attribute type %d.",
146-
attr_desc.type()));
145+
PADDLE_THROW(common::errors::Unavailable("Unsupported attribute type %d.",
146+
attr_desc.type()));
147147
}
148148
return paddle::blank();
149149
}
@@ -164,8 +164,8 @@ Attribute GetAttrValue(const proto::VarDesc::Attr& attr_desc) {
164164
return val;
165165
}
166166
default:
167-
PADDLE_THROW(phi::errors::Unavailable("Unsupported attribute type %d.",
168-
attr_desc.type()));
167+
PADDLE_THROW(common::errors::Unavailable("Unsupported attribute type %d.",
168+
attr_desc.type()));
169169
}
170170
return paddle::blank();
171171
}
@@ -184,9 +184,9 @@ paddle::experimental::Scalar MakeScalarFromProto(const proto::Scalar& v) {
184184
return paddle::experimental::Scalar(value);
185185
}
186186
default:
187-
PADDLE_THROW(
188-
phi::errors::InvalidArgument("Expected scalar of type boolean, "
189-
"integer, floating point or complex."));
187+
PADDLE_THROW(common::errors::InvalidArgument(
188+
"Expected scalar of type boolean, "
189+
"integer, floating point or complex."));
190190
break;
191191
}
192192
return paddle::experimental::Scalar();
@@ -230,14 +230,14 @@ proto::Scalar MakeScalarProto(const paddle::experimental::Scalar& v) {
230230
case phi::DataType::UNDEFINED:
231231
case phi::DataType::PSTRING:
232232
case phi::DataType::NUM_DATA_TYPES:
233-
PADDLE_THROW(
234-
phi::errors::InvalidArgument("Expected scalar of type boolean, "
235-
"integer, floating point or complex."));
233+
PADDLE_THROW(common::errors::InvalidArgument(
234+
"Expected scalar of type boolean, "
235+
"integer, floating point or complex."));
236236
break;
237237
default:
238-
PADDLE_THROW(
239-
phi::errors::InvalidArgument("Expected scalar of type boolean, "
240-
"integer, floating point or complex."));
238+
PADDLE_THROW(common::errors::InvalidArgument(
239+
"Expected scalar of type boolean, "
240+
"integer, floating point or complex."));
241241
break;
242242
}
243243
return s;
@@ -260,7 +260,7 @@ paddle::experimental::Scalar MakeScalarFromAttribute(const Attribute& v) {
260260
case proto::AttrType::FLOAT64:
261261
return paddle::experimental::Scalar(PADDLE_GET_CONST(double, v));
262262
default:
263-
PADDLE_THROW(phi::errors::InvalidArgument(
263+
PADDLE_THROW(common::errors::InvalidArgument(
264264
"Unable to construct Scalar from given Attribute of type %s",
265265
attr_type));
266266
}
@@ -287,7 +287,7 @@ std::vector<paddle::experimental::Scalar> MakeScalarsFromAttribute(
287287
return experimental::WrapAsScalars(
288288
PADDLE_GET_CONST(std::vector<double>, v));
289289
default:
290-
PADDLE_THROW(phi::errors::InvalidArgument(
290+
PADDLE_THROW(common::errors::InvalidArgument(
291291
"Unable to construct Scalars from given Attribute of type %s",
292292
attr_type));
293293
}
@@ -296,7 +296,7 @@ std::vector<paddle::experimental::Scalar> MakeScalarsFromAttribute(
296296
void CanonicalizeScalarAttrs(const proto::OpProto& op_proto,
297297
AttributeMap* attrs) {
298298
PADDLE_ENFORCE_NOT_NULL(
299-
attrs, phi::errors::InvalidArgument("attrs can not be nullptr"));
299+
attrs, common::errors::InvalidArgument("attrs can not be nullptr"));
300300
for (auto& attr : op_proto.attrs()) {
301301
proto::AttrType attr_type = attr.type();
302302
const std::string& attr_name = attr.name();

paddle/fluid/framework/attribute.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct ExtractAttribute {
5050
try {
5151
attr_value = &paddle::get<T>(attr);
5252
} catch (paddle::bad_variant_access const& bad_get) {
53-
PADDLE_THROW(phi::errors::InvalidArgument(
53+
PADDLE_THROW(common::errors::InvalidArgument(
5454
"Cannot get attribute (%s) by type %s, its type is %s.",
5555
attr_name_,
5656
paddle::platform::demangle(typeid(T).name()),
@@ -85,7 +85,7 @@ struct ExtractAttribute<bool> {
8585
try {
8686
attr_value = &paddle::get<bool>(attr);
8787
} catch (paddle::bad_variant_access const& bad_get) {
88-
PADDLE_THROW(phi::errors::InvalidArgument(
88+
PADDLE_THROW(common::errors::InvalidArgument(
8989
"Cannot get attribute (%s) by type bool, its type is %s.",
9090
attr_name_,
9191
paddle::platform::demangle(attr.type().name())));
@@ -113,7 +113,7 @@ struct ExtractAttribute<int64_t> {
113113
try {
114114
attr_value = &paddle::get<int64_t>(attr);
115115
} catch (paddle::bad_variant_access const& bad_get) {
116-
PADDLE_THROW(phi::errors::InvalidArgument(
116+
PADDLE_THROW(common::errors::InvalidArgument(
117117
"Cannot get attribute (%s) by type int64_t, its type is %s.",
118118
attr_name_,
119119
paddle::platform::demangle(attr.type().name())));
@@ -143,7 +143,7 @@ struct ExtractAttribute<std::vector<int64_t>> {
143143
try {
144144
attr_value = &paddle::get<std::vector<int64_t>>(attr);
145145
} catch (paddle::bad_variant_access const& bad_get) {
146-
PADDLE_THROW(phi::errors::InvalidArgument(
146+
PADDLE_THROW(common::errors::InvalidArgument(
147147
"Cannot get attribute (%s) by type std::vector<int64_t>, its type is "
148148
"%s.",
149149
attr_name_,
@@ -172,7 +172,7 @@ struct ExtractAttribute<float> {
172172
try {
173173
attr_value = &paddle::get<float>(attr);
174174
} catch (paddle::bad_variant_access const& bad_get) {
175-
PADDLE_THROW(phi::errors::InvalidArgument(
175+
PADDLE_THROW(common::errors::InvalidArgument(
176176
"Cannot get attribute (%s) by type float, its type is %s.",
177177
attr_name_,
178178
paddle::platform::demangle(attr.type().name())));
@@ -203,7 +203,7 @@ struct ExtractAttribute<double> {
203203
try {
204204
attr_value = &paddle::get<double>(attr);
205205
} catch (paddle::bad_variant_access const& bad_get) {
206-
PADDLE_THROW(phi::errors::InvalidArgument(
206+
PADDLE_THROW(common::errors::InvalidArgument(
207207
"Cannot get attribute (%s) by type double, its type is %s.",
208208
attr_name_,
209209
paddle::platform::demangle(attr.type().name())));
@@ -233,7 +233,7 @@ struct ExtractAttribute<std::vector<double>> {
233233
try {
234234
attr_value = &paddle::get<std::vector<double>>(attr);
235235
} catch (paddle::bad_variant_access const& bad_get) {
236-
PADDLE_THROW(phi::errors::InvalidArgument(
236+
PADDLE_THROW(common::errors::InvalidArgument(
237237
"Cannot get attribute (%s) by type std::vector<double>, its type is "
238238
"%s.",
239239
attr_name_,
@@ -255,7 +255,7 @@ struct ExtractAttribute<paddle::experimental::Scalar> {
255255
try {
256256
attr_value = &paddle::get<paddle::experimental::Scalar>(attr);
257257
} catch (paddle::bad_variant_access const& bad_get) {
258-
PADDLE_THROW(phi::errors::InvalidArgument(
258+
PADDLE_THROW(common::errors::InvalidArgument(
259259
"Cannot get attribute (%s) by type Scalar, its type is %s, index is "
260260
"%d",
261261
attr_name_,
@@ -320,7 +320,7 @@ class AttrReader {
320320
}
321321
PADDLE_ENFORCE_EQ(found,
322322
true,
323-
phi::errors::NotFound(
323+
common::errors::NotFound(
324324
"Attribute (%s) should be in AttributeMap.", name));
325325

326326
Attribute& attr = const_cast<Attribute&>(it->second);

paddle/fluid/framework/attribute_checker.h

+19-19
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class GreaterThanChecker {
2828
PADDLE_ENFORCE_GT(
2929
value,
3030
lower_bound_,
31-
phi::errors::OutOfRange("Check for attribute value greater than "
32-
"a certain value failed."));
31+
common::errors::OutOfRange("Check for attribute value greater than "
32+
"a certain value failed."));
3333
}
3434

3535
private:
@@ -44,8 +44,8 @@ class EqualGreaterThanChecker {
4444
PADDLE_ENFORCE_GE(
4545
value,
4646
lower_bound_,
47-
phi::errors::OutOfRange("Check for attribute value equal or "
48-
"greater than a certain value failed."));
47+
common::errors::OutOfRange("Check for attribute value equal or "
48+
"greater than a certain value failed."));
4949
}
5050

5151
private:
@@ -70,12 +70,12 @@ class TypedAttrVarInfoChecker {
7070
void check(const VarDesc* var_desc) const {
7171
PADDLE_ENFORCE_NOT_NULL(
7272
var_desc,
73-
phi::errors::InvalidArgument(
73+
common::errors::InvalidArgument(
7474
"Required Attribute with Variable type shall not be nullptr."));
7575
auto shape = var_desc->GetShape();
7676
PADDLE_ENFORCE_LE(shape.size(),
7777
1U,
78-
phi::errors::InvalidArgument(
78+
common::errors::InvalidArgument(
7979
"Required shape rank of Attribute(%s) <= 1, "
8080
"but received rank == %s",
8181
var_desc->Name(),
@@ -90,7 +90,7 @@ class TypedAttrVarInfoChecker {
9090
dtype == proto::VarType::Type::VarType_Type_INT64);
9191
PADDLE_ENFORCE_EQ(is_int,
9292
true,
93-
phi::errors::InvalidArgument(
93+
common::errors::InvalidArgument(
9494
"Required dtype of Attribute(%s) shall be "
9595
"int32|int64, but received %s.",
9696
var_desc->Name(),
@@ -102,20 +102,20 @@ class TypedAttrVarInfoChecker {
102102
for (auto& var_desc : var_descs) {
103103
PADDLE_ENFORCE_NOT_NULL(
104104
var_desc,
105-
phi::errors::InvalidArgument(
105+
common::errors::InvalidArgument(
106106
"Required Attribute with Variable type shall not be nullptr."));
107107
auto shape = var_desc->GetShape();
108108
PADDLE_ENFORCE_LE(shape.size(),
109109
1U,
110-
phi::errors::InvalidArgument(
110+
common::errors::InvalidArgument(
111111
"Required shape rank of Attribute(%s) <= 1, "
112112
"but received rank == %s",
113113
var_desc->Name(),
114114
shape.size()));
115115
PADDLE_ENFORCE_EQ(
116116
shape.size() == 0U || shape[0] == 1U || shape[0] == -1,
117117
true,
118-
phi::errors::InvalidArgument(
118+
common::errors::InvalidArgument(
119119
"Required shape is (), or shape[0] of Attribute(%s) == 1 or -1, "
120120
"but received shape[0] == %s",
121121
var_desc->Name(),
@@ -146,9 +146,9 @@ class EnumInContainer {
146146
PADDLE_ENFORCE_NE(
147147
container_.find(val),
148148
container_.end(),
149-
phi::errors::NotFound("Value %s is not in enum container %s.",
150-
val,
151-
ContainerDebugString()));
149+
common::errors::NotFound("Value %s is not in enum container %s.",
150+
val,
151+
ContainerDebugString()));
152152
}
153153

154154
private:
@@ -218,9 +218,9 @@ class TypedAttrChecker {
218218
PADDLE_ENFORCE_EQ(
219219
default_value_setter_.empty(),
220220
true,
221-
phi::errors::AlreadyExists("Attribute (%s) has a default value "
222-
"and cannot be set repeatedly.",
223-
attr_name_));
221+
common::errors::AlreadyExists("Attribute (%s) has a default value "
222+
"and cannot be set repeatedly.",
223+
attr_name_));
224224
default_value_setter_.push_back(DefaultValueSetter<T>(default_value));
225225
return *this;
226226
}
@@ -245,7 +245,7 @@ class TypedAttrChecker {
245245
if (it != attr_map->end() && HasAttrVar(it->second)) {
246246
PADDLE_ENFORCE_EQ(attr_->support_tensor(),
247247
true,
248-
phi::errors::InvalidArgument(
248+
common::errors::InvalidArgument(
249249
"Found Attribute('%s') with type(Variable), but it "
250250
"doesn't support phi::DenseTensor type.",
251251
attr_name_));
@@ -269,8 +269,8 @@ class TypedAttrChecker {
269269
PADDLE_ENFORCE_EQ(
270270
default_value_setter_.empty(),
271271
false,
272-
phi::errors::InvalidArgument("Attribute (%s) is not set correctly.",
273-
attr_name_));
272+
common::errors::InvalidArgument(
273+
"Attribute (%s) is not set correctly.", attr_name_));
274274
// default_value_setter_ has no more than one element
275275
auto tmp = attr_map->emplace(attr_name_, default_value_setter_[0]());
276276
it = tmp.first;

paddle/fluid/framework/block_desc.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ void BlockDesc::SetForwardBlockID(int32_t forward_block_id) {
269269
PADDLE_ENFORCE_EQ(
270270
desc_->has_forward_block_idx(),
271271
false,
272-
phi::errors::PreconditionNotMet(
272+
common::errors::PreconditionNotMet(
273273
"Block %d's parent block ID has been set to %d, cannot be set to %d.",
274274
desc_->idx(),
275275
desc_->forward_block_idx(),
@@ -283,7 +283,7 @@ BlockDesc *BlockDesc::ForwardBlock() const {
283283

284284
void BlockDesc::MoveFrom(BlockDesc *block) {
285285
PADDLE_ENFORCE_NOT_NULL(
286-
block, phi::errors::InvalidArgument("Block must be provided."));
286+
block, common::errors::InvalidArgument("Block must be provided."));
287287
if (this == block) {
288288
return;
289289
}

0 commit comments

Comments
 (0)