// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once #include #include #include class ITestCase; class TestCaseResult; class TestResultStat; namespace Ort { struct Env; struct SessionOptions; } // namespace Ort namespace onnxruntime { class Env; namespace common { class Status; } namespace concurrency { class ThreadPool; } } // namespace onnxruntime using OrtThreadPool = onnxruntime::concurrency::ThreadPool; using PThreadPool = OrtThreadPool*; /// /// Facilitates running tests /// class TestEnv { public: TestEnv(Ort::Env& env, Ort::SessionOptions& sf1, PThreadPool tp, std::vector&& tests, TestResultStat& stat1, bool inference_mode = false); ~TestEnv(); static std::unique_ptr CreateThreadPool(onnxruntime::Env& env); /// /// Runs all tests cases either concurrently or sequentially /// /// parallel_models - number of models to run concurrently /// /// /// onnxruntime::common::Status Run(size_t parallel_models, int concurrent_runs, size_t repeat_count); Ort::Env& Env() const { return env_; } const Ort::SessionOptions& GetSessionOptions() const { return so_; } PThreadPool GetThreadPool() const { return tp_; } const std::vector& GetTests() const { return tests_; } ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(TestEnv); private: void CalculateStats(const std::vector>&); Ort::Env& env_; const Ort::SessionOptions& so_; bool inference_mode_; PThreadPool tp_; std::vector tests_; TestResultStat& stat_; };