mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-20 04:23:01 +03:00
Fix ONNX Runtime CPU memory arena configuration (#25003)
* Fix CPU memory arena option on ONNX Runtime sessions * Limit CPU arena correction to CPU enrichment sessions * Retain default arena in GPU runner integration regression * Preserve native detector session-options contract
This commit is contained in:
@@ -59,10 +59,18 @@ class TestGetOrtSessionOptions(unittest.TestCase):
|
||||
ort.GraphOptimizationLevel.ORT_ENABLE_ALL,
|
||||
)
|
||||
|
||||
def test_only_cpu_enrichment_models_disable_the_cpu_arena(self):
|
||||
for model_type in EnrichmentModelTypeEnum:
|
||||
for cpu in [False, True]:
|
||||
with self.subTest(model_type=model_type, cpu=cpu):
|
||||
options = get_ort_session_options(model_type.value, cpu=cpu)
|
||||
self.assertEqual(options.enable_cpu_mem_arena, not cpu)
|
||||
|
||||
def test_detector_models_use_defaults(self):
|
||||
for model_type in [None, ModelTypeEnum.rfdetr.value]:
|
||||
with self.subTest(model_type=model_type):
|
||||
self.assertIsNone(get_ort_session_options(model_type, cpu=True))
|
||||
for cpu in [False, True]:
|
||||
with self.subTest(model_type=model_type, cpu=cpu):
|
||||
self.assertIsNone(get_ort_session_options(model_type, cpu=cpu))
|
||||
|
||||
|
||||
class TestCudaGraphRunner(unittest.TestCase):
|
||||
|
||||
@@ -140,6 +140,9 @@ class TestLoadRegistry(unittest.TestCase):
|
||||
spinning = None
|
||||
|
||||
self.assertEqual(spinning, expected)
|
||||
self.assertEqual(
|
||||
options.enable_cpu_mem_arena, provider != "CPUExecutionProvider"
|
||||
)
|
||||
|
||||
|
||||
class TestLoadedDeviceSnapshot(unittest.TestCase):
|
||||
@@ -560,4 +563,4 @@ class TestMIGraphX(unittest.TestCase):
|
||||
providers, options = model_util.get_ort_providers()
|
||||
|
||||
self.assertEqual(providers, ["CPUExecutionProvider"])
|
||||
self.assertEqual(options, [{"enable_cpu_mem_arena": False}])
|
||||
self.assertEqual(options, [{}])
|
||||
|
||||
Reference in New Issue
Block a user