|
13 | 13 | // limitations under the License. |
14 | 14 |
|
15 | 15 | #include "paddle/fluid/operators/trace_op.h" |
| 16 | +#include "paddle/fluid/framework/op_version_registry.h" |
16 | 17 |
|
17 | 18 | namespace paddle { |
18 | 19 | namespace operators { |
@@ -88,13 +89,13 @@ class TraceOpMaker : public framework::OpProtoAndCheckerMaker { |
88 | 89 | R"DOC((int, default 0), the first axis of the 2-D planes from which the diagonals should be taken. |
89 | 90 | Can be either positive or negative. Default: 0. |
90 | 91 | )DOC") |
91 | | - .SetDefault(-2); |
| 92 | + .SetDefault(0); |
92 | 93 | AddAttr<int>( |
93 | 94 | "axis2", |
94 | 95 | R"DOC((int, default 1), the second axis of the 2-D planes from which the diagonals should be taken. |
95 | 96 | Can be either positive or negative. Default: 1. |
96 | 97 | )DOC") |
97 | | - .SetDefault(-1); |
| 98 | + .SetDefault(1); |
98 | 99 | AddComment(R"DOC( |
99 | 100 | Trace Operator. |
100 | 101 | Return the sum along diagonals of the input tensor. |
@@ -177,3 +178,21 @@ REGISTER_OP_CPU_KERNEL( |
177 | 178 | paddle::platform::complex64>, |
178 | 179 | ops::TraceGradKernel<paddle::platform::CPUDeviceContext, |
179 | 180 | paddle::platform::complex128>); |
| 181 | + |
| 182 | +/* ========================== register checkpoint ===========================*/ |
| 183 | +REGISTER_OP_VERSION(trace) |
| 184 | + .AddCheckpoint( |
| 185 | + R"ROC(Upgrade trace add a new attribute [axis2])ROC", |
| 186 | + paddle::framework::compatible::OpVersionDesc() |
| 187 | + .NewAttr("axis1", |
| 188 | + "The added attribute 'axis1' is not yet registered.", |
| 189 | + std::vector<float>{0.0f}) |
| 190 | + .NewAttr("axis2", |
| 191 | + "The added attribute 'axis2' is not yet registered.", |
| 192 | + std::vector<float>{1.0f}) |
| 193 | + .DeleteAttr("dim1", |
| 194 | + "The attribute 'dim1' is not recommend according to " |
| 195 | + "the specification 2.0.") |
| 196 | + .DeleteAttr("dim2", |
| 197 | + "The attribute 'dim2' is not recommend according to " |
| 198 | + "the specification 2.0.")); |
0 commit comments