提交 b43ea40c 编写于 作者: N nhzlx

delete the usage of the const_cast

test=develop
上级 92cf4a4c
...@@ -67,10 +67,8 @@ void IRPassManager::CreatePasses(Argument *argument, ...@@ -67,10 +67,8 @@ void IRPassManager::CreatePasses(Argument *argument,
pass->Set("max_batch_size", new int(argument->tensorrt_max_batch_size())); pass->Set("max_batch_size", new int(argument->tensorrt_max_batch_size()));
pass->Set("min_subgraph_size", pass->Set("min_subgraph_size",
new int(argument->tensorrt_min_subgraph_size())); new int(argument->tensorrt_min_subgraph_size()));
pass->Set( pass->Set("program",
"program", new framework::ProgramDesc *(&argument->main_program()));
new framework::ProgramDesc *(
const_cast<framework::ProgramDesc *>(&argument->main_program())));
bool enable_int8 = argument->tensorrt_precision_mode() == bool enable_int8 = argument->tensorrt_precision_mode() ==
contrib::AnalysisConfig::Precision::kInt8; contrib::AnalysisConfig::Precision::kInt8;
......
...@@ -114,9 +114,9 @@ class TensorRTEngineOp : public framework::OperatorBase { ...@@ -114,9 +114,9 @@ class TensorRTEngineOp : public framework::OperatorBase {
framework::Executor executor(dev_place); framework::Executor executor(dev_place);
auto *block = Attr<framework::BlockDesc *>("sub_block"); auto *block = Attr<framework::BlockDesc *>("sub_block");
auto *program = block->Program(); auto *program = block->Program();
auto *scope_ptr = const_cast<framework::Scope *>(&scope); auto &current_scope = scope.NewScope();
auto ctx = executor.Prepare(*program, block->ID()); 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, void RunImpl(const framework::Scope &scope,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册