Skip to content

Commit 186b2b1

Browse files
authored
Revert "Merge pull request #13201 from reyoung/revert_callstack" (#13697)
This reverts commit 21bb9e9, reversing changes made to 3fa68dc. test=develop
1 parent a89afd4 commit 186b2b1

File tree

8 files changed

+17
-71
lines changed

8 files changed

+17
-71
lines changed

paddle/fluid/framework/op_proto_maker.cc

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

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

paddle/fluid/framework/op_proto_maker.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class OpProtoAndCheckerMaker {
4646
static const char *OpRoleAttrName() { return "op_role"; }
4747
static const char *OpRoleVarAttrName() { return "op_role_var"; }
4848
static const char *OpNamescopeAttrName() { return "op_namescope"; }
49-
static const char *OpCreationCallstackAttrName() { return "op_callstack"; }
5049

5150
void operator()(proto::OpProto *proto, OpAttrChecker *attr_checker);
5251

paddle/fluid/framework/operator.cc

Lines changed: 13 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,15 @@ limitations under the License. */
1414
#define GLOG_NO_ABBREVIATED_SEVERITIES
1515
#define GOOGLE_GLOG_DLL_DECL
1616

17-
#include "paddle/fluid/framework/operator.h"
1817
#include <gflags/gflags.h>
1918
#include <glog/logging.h>
19+
2020
#include <algorithm>
21-
#include <sstream>
22-
#include <string>
23-
#include <vector>
21+
2422
#include "paddle/fluid/framework/data_transform.h"
2523
#include "paddle/fluid/framework/executor.h"
2624
#include "paddle/fluid/framework/lod_tensor.h"
27-
#include "paddle/fluid/framework/op_proto_maker.h"
25+
#include "paddle/fluid/framework/operator.h"
2826
#include "paddle/fluid/framework/shape_inference.h"
2927
#include "paddle/fluid/framework/var_type.h"
3028
#include "paddle/fluid/platform/profiler.h"
@@ -142,54 +140,19 @@ static LoD GetLoD(const Scope& scope, const std::string& name) {
142140
}
143141

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

195158
bool OperatorBase::HasInputs(const std::string& name) const {
@@ -217,7 +180,7 @@ const std::vector<std::string>& OperatorBase::Inputs(
217180
}
218181

219182
bool OperatorBase::HasOutputs(const std::string& name) const {
220-
if (outputs_.end() != outputs_.find(name)) {
183+
if (outputs_.find(name) != outputs_.end()) {
221184
return true;
222185
} else {
223186
return false;

paddle/fluid/operators/tensorrt_engine_op.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace operators {
3434
using FluidDT = framework::proto::VarType_Type;
3535
using TRT_DT = nvinfer1::DataType;
3636

37-
namespace { // NOLINT
37+
namespace {
3838

3939
TRT_DT FluidDataType2TRT(FluidDT type) {
4040
switch (type) {

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
@@ -48,9 +48,6 @@ void BindConstValue(pybind11::module* m) {
4848
op_proto_and_checker_maker.def(
4949
"kOpNameScopeAttrName",
5050
framework::OpProtoAndCheckerMaker::OpNamescopeAttrName);
51-
op_proto_and_checker_maker.def(
52-
"kOpCreationCallstackAttrName",
53-
framework::OpProtoAndCheckerMaker::OpCreationCallstackAttrName);
5451
}
5552

5653
} // namespace pybind

python/paddle/fluid/framework.py

Lines changed: 1 addition & 10 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

@@ -35,8 +34,6 @@
3534
except Exception as e:
3635
raise e
3736
from . import unique_name
38-
import os
39-
PADDLE_ON_MODEL_CE = os.environ.get('PADDLE_ON_MODEL_CE', None) is not None
4037

4138
__all__ = [
4239
'Program',
@@ -490,8 +487,7 @@ def generated_op_attr_names():
490487
return {
491488
core.op_proto_and_checker_maker.kOpRoleAttrName(),
492489
core.op_proto_and_checker_maker.kOpRoleVarAttrName(),
493-
core.op_proto_and_checker_maker.kOpNameScopeAttrName(),
494-
core.op_proto_and_checker_maker.kOpCreationCallstackAttrName()
490+
core.op_proto_and_checker_maker.kOpNameScopeAttrName()
495491
}
496492

497493

@@ -573,11 +569,6 @@ def __init__(self,
573569
if role_var_name in op_attrs and len(op_attrs[role_var_name]) == 0:
574570
del op_attrs[role_var_name]
575571

576-
if not PADDLE_ON_MODEL_CE:
577-
callstack_var_name = op_maker.kOpCreationCallstackAttrName()
578-
op_attrs[callstack_var_name] = list(
579-
reversed(traceback.format_stack()))[1:]
580-
581572
if len(self.desc.type()) != 0:
582573
return
583574
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)