Skip to content

Commit 1c87558

Browse files
author
Yibing Liu
committed
Revert changes for debug
1 parent 8edf60c commit 1c87558

File tree

7 files changed

+17
-61
lines changed

7 files changed

+17
-61
lines changed

paddle/fluid/framework/op_proto_maker.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ void OpProtoAndCheckerMaker::operator()(proto::OpProto* proto,
131131

132132
AddAttr<std::string>(OpNamescopeAttrName(), "Operator name with namesope.")
133133
.SetDefault("");
134-
AddAttr<std::vector<std::string>>(OpCreationCallstackAttrName(),
135-
"Callstack for Op Creatation.")
136-
.SetDefault({});
134+
137135
Validate();
138136
}
139137

paddle/fluid/framework/op_proto_maker.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class OpProtoAndCheckerMaker {
4040
static const char *OpRoleAttrName() { return "op_role"; }
4141
static const char *OpRoleVarAttrName() { return "op_role_var"; }
4242
static const char *OpNamescopeAttrName() { return "op_namescope"; }
43-
static const char *OpCreationCallstackAttrName() { return "op_callstack"; }
4443

4544
void operator()(proto::OpProto *proto, OpAttrChecker *attr_checker);
4645

paddle/fluid/framework/operator.cc

Lines changed: 15 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@ distributed under the License is distributed on an "AS IS" BASIS,
1111
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License. */
14-
#include "paddle/fluid/framework/operator.h"
14+
#include <gflags/gflags.h>
15+
#include <glog/logging.h>
16+
1517
#include <algorithm>
16-
#include <sstream>
17-
#include <string>
18-
#include <vector>
19-
#include "gflags/gflags.h"
20-
#include "glog/logging.h"
18+
2119
#include "paddle/fluid/framework/data_transform.h"
2220
#include "paddle/fluid/framework/executor.h"
2321
#include "paddle/fluid/framework/lod_tensor.h"
24-
#include "paddle/fluid/framework/op_proto_maker.h"
22+
#include "paddle/fluid/framework/operator.h"
2523
#include "paddle/fluid/framework/shape_inference.h"
2624
#include "paddle/fluid/framework/var_type.h"
2725
#include "paddle/fluid/platform/profiler.h"
@@ -139,48 +137,19 @@ static LoD GetLoD(const Scope& scope, const std::string& name) {
139137
}
140138

141139
void OperatorBase::Run(const Scope& scope, const platform::Place& place) {
142-
try {
143-
if (VLOG_IS_ON(4)) {
144-
VLOG(4) << place << " " << DebugStringEx(&scope);
145-
}
146-
if (platform::is_gpu_place(place)) {
140+
VLOG(4) << place << " " << DebugStringEx(&scope);
141+
if (platform::is_gpu_place(place)) {
147142
#ifndef PADDLE_WITH_CUDA
148-
PADDLE_THROW("Cannot run operator on place %s", place);
143+
PADDLE_THROW("Cannot run operator on place %s", place);
149144
#else
150-
auto dev_id = boost::get<platform::CUDAPlace>(place).device;
151-
platform::SetDeviceId(dev_id);
145+
auto dev_id = boost::get<platform::CUDAPlace>(place).device;
146+
platform::SetDeviceId(dev_id);
152147
#endif
153-
}
154-
platform::DeviceContextPool& pool = platform::DeviceContextPool::Instance();
155-
platform::RecordEvent record_event(Type(), pool.Get(place));
156-
RunImpl(scope, place);
157-
if (VLOG_IS_ON(3)) {
158-
VLOG(3) << place << " " << DebugStringEx(&scope);
159-
}
160-
} catch (platform::EnforceNotMet exception) {
161-
if (Attrs().count("sub_block") != 0) {
162-
throw exception;
163-
}
164-
165-
auto& callstack = Attr<std::vector<std::string>>(
166-
OpProtoAndCheckerMaker::OpCreationCallstackAttrName());
167-
168-
if (callstack.empty()) {
169-
throw exception;
170-
}
171-
std::ostringstream sout;
172-
sout << "Invoke operator " << Type() << " error.\n";
173-
sout << "Python Callstacks: \n";
174-
for (auto& line : callstack) {
175-
sout << line;
176-
}
177-
sout << "C++ Callstacks: \n";
178-
sout << exception.err_str_;
179-
exception.err_str_ = sout.str();
180-
throw exception;
181-
} catch (...) {
182-
std::rethrow_exception(std::current_exception());
183148
}
149+
platform::DeviceContextPool& pool = platform::DeviceContextPool::Instance();
150+
platform::RecordEvent record_event(Type(), pool.Get(place));
151+
RunImpl(scope, place);
152+
VLOG(3) << place << " " << DebugStringEx(&scope);
184153
}
185154

186155
bool OperatorBase::HasInputs(const std::string& name) const {
@@ -208,7 +177,7 @@ const std::vector<std::string>& OperatorBase::Inputs(
208177
}
209178

210179
bool OperatorBase::HasOutputs(const std::string& name) const {
211-
if (outputs_.end() != outputs_.find(name)) {
180+
if (outputs_.find(name) != outputs_.end()) {
212181
return true;
213182
} else {
214183
return false;

paddle/fluid/operators/top_k_op.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ class TopkOp : public framework::OperatorWithKernel {
3030
"Output(Indices) of TopkOp should not be null.");
3131

3232
auto input_dims = ctx->GetInputDim("X");
33-
PADDLE_ENFORCE_EQ(input_dims.size(), 2,
34-
"Rank of TopK op's input must be 2.");
3533
const int k = static_cast<int>(ctx->Attrs().Get<int>("k"));
3634

3735
PADDLE_ENFORCE_GE(k, 1, "k must >= 1");

paddle/fluid/pybind/const_value.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ void BindConstValue(pybind11::module* m) {
4646
op_proto_and_checker_maker.def(
4747
"kOpNameScopeAttrName",
4848
framework::OpProtoAndCheckerMaker::OpNamescopeAttrName);
49-
op_proto_and_checker_maker.def(
50-
"kOpCreationCallstackAttrName",
51-
framework::OpProtoAndCheckerMaker::OpCreationCallstackAttrName);
5249
}
5350

5451
} // namespace pybind

python/paddle/fluid/framework.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import contextlib
1919
import re
2020
import six
21-
import traceback
2221

2322
import numpy as np
2423

@@ -573,10 +572,6 @@ def __init__(self,
573572
if role_var_name in op_attrs and len(op_attrs[role_var_name]) == 0:
574573
del op_attrs[role_var_name]
575574

576-
callstack_var_name = op_maker.kOpCreationCallstackAttrName()
577-
op_attrs[callstack_var_name] = list(
578-
reversed(traceback.format_stack()))[1:]
579-
580575
if len(self.desc.type()) != 0:
581576
return
582577
if type is None:

python/paddle/fluid/tests/unittests/test_operator_desc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_op_desc_creation(self):
6969
set(mul_op.attr_names),
7070
set([
7171
"x_num_col_dims", "y_num_col_dims", "op_role", "op_role_var",
72-
"op_namescope", "op_callstack"
72+
"op_namescope"
7373
]))
7474
self.assertEqual(mul_op.has_attr("x_num_col_dims"), True)
7575
self.assertEqual(mul_op.attr_type("x_num_col_dims"), core.AttrType.INT)

0 commit comments

Comments
 (0)