delete the usage of the const_cast

test=develop
inference-pre-release-gpu
nhzlx 6 years ago
parent 92cf4a4c6b
commit b43ea40c51

@ -67,10 +67,8 @@ void IRPassManager::CreatePasses(Argument *argument,
pass->Set("max_batch_size", new int(argument->tensorrt_max_batch_size()));
pass->Set("min_subgraph_size",
new int(argument->tensorrt_min_subgraph_size()));
pass->Set(
"program",
new framework::ProgramDesc *(
const_cast<framework::ProgramDesc *>(&argument->main_program())));
pass->Set("program",
new framework::ProgramDesc *(&argument->main_program()));
bool enable_int8 = argument->tensorrt_precision_mode() ==
contrib::AnalysisConfig::Precision::kInt8;

@ -114,9 +114,9 @@ class TensorRTEngineOp : public framework::OperatorBase {
framework::Executor executor(dev_place);
auto *block = Attr<framework::BlockDesc *>("sub_block");
auto *program = block->Program();
auto *scope_ptr = const_cast<framework::Scope *>(&scope);
auto &current_scope = scope.NewScope();
auto ctx = executor.Prepare(*program, block->ID());
executor.RunPreparedContext(ctx.get(), scope_ptr, false, true, true);
executor.RunPreparedContext(ctx.get(), &current_scope, false, true, true);
}
void RunImpl(const framework::Scope &scope,

Loading…
Cancel
Save