Repository: microsoft/onnxruntime
File: onnxruntime/test/providers/nv_tensorrt_rtx/nv_basic_test.cc (C++)

Code before:
  CreateBaseModel(model_name, graph_name, dims, false, GetParam());

  // AOT time
  {
    Ort::SessionOptions so;
    Ort::RunOptions run_options;
    so.AppendExecutionProvider(kNvTensorRTRTXExecutionProvider, {});
    Ort::Session session_object(*ort_env, model_name.c_str(), so);

    auto io_binding = generate_io_binding(session_object);
    session_object.Run(run_options, io_binding);
  }
}

TEST(NvExecutionProviderTest, TestSessionOutputs) {
  /*
   * Model #1:
   *
   * "input" ---> TopK ---
   *                     |---> "scores"
   *                     |--- Less ---> "Less_output_0"
   *                     |--- Div ---> "Div_output_0"
   *                     |--- Mod ---> "labels"
   */
  {
    Ort::Env env{ORT_LOGGING_LEVEL_WARNING, "test"};
    Ort::SessionOptions session_options;
    session_options.AppendExecutionProvider(kNvTensorRTRTXExecutionProvider, {});

    auto model_path = ORT_TSTR("model_with_topk_and_multiple_graph_outputs.onnx");
    Ort::Status status(CreateModelWithTopKWhichContainsGraphOutput(model_path));
    ASSERT_TRUE(status.IsOK());

    Ort::Session session(env, model_path, session_options);

    size_t output_count = session.GetOutputCount();
    ASSERT_TRUE(output_count == 4);
  }

  /*
   * Model #2:
   *
   * "X" ---> Dropout ---> MatMul ---> "Y"
   *          ^     |
   *          |     |
   * "W" ------     ----> Can't be graph's output
   *
   */
  {
    Ort::Env env{ORT_LOGGING_LEVEL_WARNING, "test"};
    Ort::SessionOptions session_options;

Review comment (suggestion):
there's already a global `Ort::Env` instance [here](https://github.com/microsoft/onnxruntime/blob/186c938c014019b2ca5d80320631db6419bc687c/onnxruntime/test/unittest_main/test_main.cc#L40) - why do we need to define another one? the underlying `OrtEnv` is a singleton so this would refer to the same instance.

Code after:
  CreateBaseModel(model_name, graph_name, dims, false, GetParam());

  // AOT time
  {
    Ort::SessionOptions so;
    Ort::RunOptions run_options;
    so.AppendExecutionProvider(kNvTensorRTRTXExecutionProvider, {});
    Ort::Session session_object(*ort_env, model_name.c_str(), so);

    auto io_binding = generate_io_binding(session_object);
    session_object.Run(run_options, io_binding);
  }
}

TEST(NvExecutionProviderTest, TestSessionOutputs) {
  /*
   * Model #1:
   *
   * "input" ---> TopK ---
   *                     |---> "scores"
   *                     |--- Less ---> "Less_output_0"
   *                     |--- Div ---> "Div_output_0"
   *                     |--- Mod ---> "labels"
   */
  {
    Ort::SessionOptions session_options;
    session_options.AppendExecutionProvider(kNvTensorRTRTXExecutionProvider, {});

    auto model_path = ORT_TSTR("testdata/topk_and_multiple_graph_outputs.onnx");
    Ort::Session session(*ort_env, model_path, session_options);

    size_t output_count = session.GetOutputCount();
    ASSERT_TRUE(output_count == 4);
  }

  /*
   * Model #2:
   *
   * "X" ---> Dropout ---> MatMul ---> "Y"
   *          ^     |
   *          |     |
   * "W" ------     ----> Can't be graph's output
   *
   */
  {
    Ort::SessionOptions session_options;
    session_options.AppendExecutionProvider(kNvTensorRTRTXExecutionProvider, {});

    auto model_path = ORT_TSTR("testdata/node_output_not_used.onnx");
    Ort::Session session(*ort_env, model_path, session_options);