message: feat(//core/conversion): Adding a check to detect programs that will
  result in empty engines and error out
diff: @@ -433,6 +433,30 @@ std::set<std::string> GetUnsupportedOpsInBlock(const torch::jit::Block* b) {
  return unsupported_ops;
  }
  +std::set<std::string> ConvertableOpsInBlock(const torch::jit::Block* b) {
  + std::set<std::string> convertable_ops;
  + for (const auto n : b->nodes()) {
  + if (n->kind() == torch::jit::prim::Loop || n->kind() == torch::jit::prim::If || converters::node_is_convertable(n)) {
  + if (n->blocks().size() > 0) {
  + for (const auto sub_b : n->blocks()) {
  + auto sub_b_convertable_ops = ConvertableOpsInBlock(sub_b);
  + convertable_ops.insert(sub_b_convertable_ops.begin(), sub_b_convertable_ops.end());
  + }
  + }
  + if (converters::node_is_convertable(n)) {
  + auto schema = n->maybeSchema();
  + TRTORCH_CHECK(
  + schema,
  + "Unable to get schema for Node " << util::node_info(n) << " (conversion.CheckForConvertableOps)");
  + std::stringstream ss;
  + ss << *schema;
  + convertable_ops.insert(ss.str());
  + }
  + }
  + }
  + return convertable_ops;
  +}
  +
  bool VerifyConverterSupportForBlock(const torch::jit::Block* b) {
  auto unsupported_ops = GetUnsupportedOpsInBlock(b);
  @@ -448,7 +472,19 @@ bool VerifyConverterSupportForBlock(const torch::jit::Block* b) {
  unsupported_msg << "https://www.github.com/nvidia/TRTorch/issues" << std::endl;
  LOG_ERROR(unsupported_msg.str());
  return false;
  - } else {
  + }
  +
  + if (ConvertableOpsInBlock(b).size() == 0) {
  + std::stringstream unsupported_msg;
  + unsupported_msg << "Method requested cannot be compiled by TRTorch.\nThere is no work to be done since the resulting compiled program will contain an engine that is empty."
  + << std::endl;
  + unsupported_msg << "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."
  + << std::endl;
  + LOG_ERROR(unsupported_msg.str());
  + return false;
  + }
  +
  + else {
  return true;
  }
  }
  