OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
Fix missing .lower() call in _is_testing() and add unit tests (#37321)
Ritesh Kumar Mishra2e87e3fb8cbf
diff --git a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/backend_utils.py b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/backend_utils.pyindex dae7a7ccf0a..6e14ffaec3c 100644--- a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/backend_utils.py+++ b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/backend_utils.py@@ -83,6 +83,6 @@ def _get_disabled_ops(options) -> Optional[Any]:def _is_testing(options) -> Optional[Any]:if options is not None and "testing" in options:is_testing = options["testing"]- if bool(is_testing) and str(is_testing).lower not in ["false", "0"]:+ if bool(is_testing) and str(is_testing).lower() not in ["false", "0"]:return Truereturn Falsediff --git a/tests/layer_tests/py_frontend_tests/test_torch_decoder.py b/tests/layer_tests/py_frontend_tests/test_torch_decoder.pyindex d9e02596ef5..e5214b35ad2 100644--- a/tests/layer_tests/py_frontend_tests/test_torch_decoder.py+++ b/tests/layer_tests/py_frontend_tests/test_torch_decoder.py@@ -5,7 +5,7 @@import torchimport pytestfrom packaging import version-+from openvino.frontend.pytorch.torchdynamo.backend_utils import _is_testingclass AtenDiv(torch.nn.Module):# aten::div can have str or NoneType constant@@ -778,3 +778,20 @@ def test_pytorch_fx_decoder_extracts_signature():assert nc_decoder.get_input_signature_name(0) == "a"assert nc_decoder.get_input_signature_name(1) == "b"assert nc_decoder._input_signature == ["a", "b"]+++ ("testing_value", "expected"),+ [+ ("false", False),+ ("0", False),+ (False, False),+ ("true", True),+ ("1", True),+ (True, True),+ ],+)+def test_is_testing_flag(testing_value, expected):+ """Test that the _is_testing flag evaluates correctly."""+ assert _is_testing({"testing": testing_value}) == expected+\ No newline at end of file