mkolod commented on a change in pull request #11325: [MXNET-703] TensorRT
runtime integration
URL: https://github.com/apache/incubator-mxnet/pull/11325#discussion_r205894970
##########
File path: src/executor/graph_executor.cc
##########
@@ -1018,20 +1156,49 @@ void GraphExecutor::Init(nnvm::Symbol symbol,
g.GetAttr<StorageTypeVector>("storage_type"));
}
+ if (use_tensorrt_) {
+ #if MXNET_USE_TENSORRT
+ // check that this graph is inference-only
+ if (std::any_of(grad_req_types->begin(), grad_req_types->end(),
+ [](const OpReqType& op){return op != kNullOp;})) {
+ LOG(FATAL) << "MXNET_USE_TENSORRT set but graph is not
inference-only. "
+ << "If it is an inference graph, set grad_req to null during
simple_bind call. "
+ << "If it is a training graph, unset the MXNET_USE_TENSORRT env
variable";
+ }
+ if (shared_buffer->empty()) {
+ LOG(FATAL) << "MXNET_USE_TENSORRT = 1 but shared_buffer is empty."
+ << "Please provide weights and other parameters, such as "
+ << "BatchNorm moments, via the shared_buffer, during simple bind
call.";
+ }
+ auto trt_groups = GetTrtCompatibleSubsets(g, shared_buffer);
+ for (auto trt_group : trt_groups) {
+ if (trt_group.size() > 1) {
+ g = ReplaceSubgraph(std::move(g), trt_group, shared_buffer);
+ g = ReinitGraph(std::move(g), default_ctx, ctx_map,
in_arg_ctxes, arg_grad_ctxes,
+ aux_state_ctxes, grad_req_types, arg_shape_map,
arg_dtype_map,
+ arg_stype_map, shared_buffer);
Review comment:
@Caenorst could you reply to @zheng-da's question above? Thanks!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services