8
8
#include " core/util/prelude.h"
9
9
10
10
#include " c10/util/intrusive_ptr.h"
11
+ #include " core/conversion/converters/converter_util.h"
11
12
#include " core/conversion/tensorcontainer/TensorContainer.h"
13
+ #include " core/util/trt_util.h"
12
14
13
15
namespace torch_tensorrt {
14
16
namespace core {
@@ -212,6 +214,21 @@ void MarkOutputs(ConversionCtx* ctx, at::ArrayRef<const torch::jit::Value*> outp
212
214
LOG_INFO (
213
215
ctx->logger , " Marking Output " << out->debugName () << " named " << name << " in engine (ctx.MarkOutput)" );
214
216
ctx->num_outputs += 1 ;
217
+ } else if (out_ivalue.isTuple ()) {
218
+ TORCHTRT_THROW_ERROR (" Tuple type. Only a single tensor or a TensorList type is supported." );
219
+ } else if (out_ivalue.isList ()) {
220
+ TORCHTRT_THROW_ERROR (" List type. Only a single tensor or a TensorList type is supported." );
221
+ } else if (out_ivalue.isScalar ()) {
222
+ TORCHTRT_THROW_ERROR (" Scalar type. Only a single tensor or a TensorList type is supported." );
223
+ } else if (out_ivalue.isTensor ()) {
224
+ // prim::NumToTensor will go to here
225
+ std::string name = std::string (" output_" ) + std::to_string (ctx->num_outputs );
226
+ auto out_tensor = converters::tensor_to_const (ctx, out_ivalue.toTensor (), " " );
227
+ out_tensor->setName (name.c_str ());
228
+ ctx->net ->markOutput (*out_tensor);
229
+ LOG_INFO (
230
+ ctx->logger , " Marking Output " << out->debugName () << " named " << name << " in engine (ctx.MarkOutput)" );
231
+ ctx->num_outputs += 1 ;
215
232
} else {
216
233
TORCHTRT_THROW_ERROR (" Unknown output type. Only a single tensor or a TensorList type is supported." );
217
234
}
@@ -364,6 +381,7 @@ void ConvertBlockToNetDef(
364
381
ConversionInfo& build_info,
365
382
ir::StaticParams& static_params) {
366
383
LOG_INFO (ctx->logger , " Converting Block" );
384
+ LOG_DEBUG (ctx->logger , *b->owningGraph ());
367
385
368
386
auto inputs = b->inputs ();
369
387
AddParamsToCtxValueMap (ctx, static_params);
@@ -508,24 +526,37 @@ bool VerifyConverterSupportForBlock(const torch::jit::Block* b, bool suppress_er
508
526
unsupported_msg << " https://www.github.com/nvidia/Torch-TensorRT/issues" << std::endl;
509
527
unsupported_msg << std::endl << " In Module:" << std::endl;
510
528
511
- if (suppress_errors) {
529
+ if (! suppress_errors) {
512
530
LOG_ERROR (unsupported_msg.str ());
513
531
}
514
532
533
+ std::unordered_map<std::string, std::unordered_set<std::string>> unsupported_node_locations;
515
534
for (const auto n : b->nodes ()) {
516
535
auto schema = n->maybeSchema ();
517
536
if (schema) {
518
537
for (const auto & x : unsupported_ops) {
519
538
if (x.first == schema->operator_name ()) {
520
- if (suppress_errors) {
521
- LOG_ERROR (
522
- " Unsupported operator: " << *schema << std::endl
523
- << torch_tensorrt::core::util::GetPyTorchSourceCode (n) << std::endl);
539
+ auto loc = unsupported_node_locations.find (x.second );
540
+ if (loc == unsupported_node_locations.end ()) {
541
+ unsupported_node_locations.insert ({x.second , {torch_tensorrt::core::util::GetPyTorchSourceCode (n)}});
542
+ } else {
543
+ loc->second .insert (torch_tensorrt::core::util::GetPyTorchSourceCode (n));
524
544
}
525
545
}
526
546
}
527
547
}
528
548
}
549
+
550
+ for (const auto & type : unsupported_node_locations) {
551
+ std::stringstream traceback;
552
+ traceback << " Unsupported operator: " << type.first << std::endl;
553
+ for (const auto & str : type.second ) {
554
+ traceback << str;
555
+ }
556
+ auto tb_str = traceback.str ();
557
+ LOG_ERROR (tb_str);
558
+ }
559
+
529
560
return false ;
530
561
}
531
562
@@ -537,7 +568,7 @@ bool VerifyConverterSupportForBlock(const torch::jit::Block* b, bool suppress_er
537
568
unsupported_msg
538
569
<< " This may be because there are no operators that can be added to the TensorRT graph or all operators have a resolved compile time value."
539
570
<< std::endl;
540
- if (suppress_errors) {
571
+ if (! suppress_errors) {
541
572
LOG_ERROR (unsupported_msg.str ());
542
573
}
543
574
return false ;
0 commit comments