Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

Initial Export Llama Lib support for Executorch (#30557)

Mustafa Cavusb16b776ac119
diff --git a/.github/workflows/job_pytorch_fx_layer_tests.yml b/.github/workflows/job_pytorch_fx_layer_tests.yml
new file mode 100644
index 00000000000..e3d620d7bff
--- /dev/null
+++ b/.github/workflows/job_pytorch_fx_layer_tests.yml
@@ -0,0 +1,139 @@
+name: PyTorch FX Layer Tests
+
+on:
+ workflow_call:
+ inputs:
+ runner:
+ description: 'Machine on which the tests would run'
+ type: string
+ required: true
+ container:
+ description: 'JSON to be converted to the value of the "container" configuration for the job'
+ type: string
+ required: false
+ default: '{"image": null}'
+ affected-components:
+ description: 'Components that are affected by changes in the commit defined by the Smart CI Action'
+ type: string
+ required: true
+ python-version:
+ description: 'Python version to setup. E.g., "3.11"'
+ type: string
+ required: true
+
+permissions: read-all
+
+env:
+ PIP_CACHE_PATH_LINUX: /mount/caches/pip/linux
+ PIP_CACHE_PATH_WIN: "C:\\mount\\caches\\pip\\win"
+
+jobs:
+ PyTorch_FX_Layer_Tests:
+ name: PyTorch FX Layer Tests
+ timeout-minutes: 60
+ runs-on: ${{ inputs.runner }}
+ container: ${{ fromJSON(inputs.container) }}
+ defaults:
+ run:
+ shell: ${{ contains(inputs.runner, 'win') && 'pwsh' || 'bash' }}
+ env:
+ DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input
+ OPENVINO_REPO: ${{ github.workspace }}/openvino
+ INSTALL_DIR: ${{ github.workspace }}/install
+ INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests
+ INSTALL_WHEELS_DIR: ${{ github.workspace }}/install/wheels
+ LAYER_TESTS_INSTALL_DIR: ${{ github.workspace }}/install/tests/layer_tests
+ USE_SYSTEM_CACHE: False # Using remote HuggingFace cache
+ steps:
+ - name: Download OpenVINO artifacts (tarballs)
+ uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
+ with:
+ pattern: openvino_[tests]*
+ path: ${{ env.INSTALL_DIR }}
+ merge-multiple: true
+
+ - name: Download OpenVINO artifacts (wheels)
+ uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
+ with:
+ pattern: openvino_[wheels]*
+ path: ${{ env.INSTALL_WHEELS_DIR }}
+ merge-multiple: true
+
+ # Needed as ${{ github.workspace }} is not working correctly when using Docker
+ - name: Setup Variables
+ if: runner.os != 'Windows'
+ run: |
+ echo "OPENVINO_REPO=$GITHUB_WORKSPACE/openvino" >> "$GITHUB_ENV"
+ echo "INSTALL_DIR=$GITHUB_WORKSPACE/install" >> "$GITHUB_ENV"
+ echo "INSTALL_TEST_DIR=$GITHUB_WORKSPACE/install/tests" >> "$GITHUB_ENV"
+ echo "INSTALL_WHEELS_DIR=$GITHUB_WORKSPACE/install/wheels" >> "$GITHUB_ENV"
+ echo "LAYER_TESTS_INSTALL_DIR=$GITHUB_WORKSPACE/install/tests/layer_tests" >> "$GITHUB_ENV"
+ echo "HF_HUB_CACHE=/mount/caches/huggingface" >> "$GITHUB_ENV"
+
+ - name: Setup HuggingFace Cache Directory (Windows)
+ if: runner.os == 'Windows'
+ run: Add-Content -Path $env:GITHUB_ENV -Value "HF_HUB_CACHE=C:\\mount\\caches\\huggingface"
+
+ - name: Install OpenVINO dependencies (mac)
+ if: runner.os == 'macOS'
+ run: brew install pigz
+
+ - name: Extract OpenVINO packages (Linux, macOS)
+ if: runner.os != 'Windows'
+ run: |
+ pigz -dc openvino_tests.tar.gz | tar -xf - -C ${INSTALL_DIR}
+ working-directory: ${{ env.INSTALL_DIR }}
+
+ - name: Extract OpenVINO artifacts (Windows)
+ if: runner.os == 'Windows'
+ run: |
+ Expand-Archive openvino_tests.zip -DestinationPath ${{ env.INSTALL_DIR }}
+ working-directory: ${{ env.INSTALL_DIR }}
+
+ - name: Fetch setup_python and install wheels actions
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ timeout-minutes: 15
+ with:
+ sparse-checkout: |
+ .github/actions/setup_python/action.yml
+ .github/actions/install_ov_wheels/action.yml
+ sparse-checkout-cone-mode: false
+ path: 'openvino'
+
+ - name: Setup Python ${{ inputs.python-version }}
+ uses: ./openvino/.github/actions/setup_python
+ with:
+ version: ${{ inputs.python-version }}
+ pip-cache-path: ${{ runner.os == 'Linux' && env.PIP_CACHE_PATH_LINUX || env.PIP_CACHE_PATH_WIN }}
+ should-setup-pip-paths: ${{ runner.os != 'macOS' }}
+ self-hosted-runner: ${{ runner.os != 'macOS' }}
+
+ - name: Install OpenVINO Python wheels
+ uses: ./openvino/.github/actions/install_ov_wheels
+ with:
+ wheels-dir-path: ${{ env.INSTALL_WHEELS_DIR }}
+ wheels-to-install: 'openvino'
+
+ - name: Install Pytorch FX Layer tests dependencies
+ run: |
+ # pytorch test requirements
+ python3 -m pip install -r ${{ env.INSTALL_TEST_DIR }}/requirements_pytorch
+
+ - name: PyTorch torch.compile TORCHFX Layer Tests
+ if: ${{ fromJSON(inputs.affected-components).PyTorch_FE.test && runner.os != 'macOS' && runner.arch != 'ARM64' && runner.os != 'Windows' }} # Ticket: 126287
+ run: |
+ python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/pytorch_tests -m precommit_fx_backend -v --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-pytorch_compile.xml
+ env:
+ TEST_DEVICE: CPU
+ TEST_PRECISION: FP32
+ PYTORCH_TRACING_MODE: TORCHFX
+
+ - name: Upload Test Results
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
+ if: ${{ !cancelled() }}
+ with:
+ name: test-results-python-pytorch-fx-layers
+ path: |
+ ${{ env.INSTALL_TEST_DIR }}/TEST*.html
+ ${{ env.INSTALL_TEST_DIR }}/TEST*.xml
+ if-no-files-found: 'warn'
diff --git a/.github/workflows/job_pytorch_layer_tests.yml b/.github/workflows/job_pytorch_layer_tests.yml
index 8f888beadd7..040273571be 100644
--- a/.github/workflows/job_pytorch_layer_tests.yml
+++ b/.github/workflows/job_pytorch_layer_tests.yml
@@ -51,7 +51,7 @@ jobs:
pattern: openvino_[tests]*
path: ${{ env.INSTALL_DIR }}
merge-multiple: true
-
+
- name: Download OpenVINO artifacts (wheels)
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
@@ -73,11 +73,11 @@ jobs:
- name: Setup HuggingFace Cache Directory (Windows)
if: runner.os == 'Windows'
run: Add-Content -Path $env:GITHUB_ENV -Value "HF_HUB_CACHE=C:\\mount\\caches\\huggingface"
-
+
- name: Install OpenVINO dependencies (mac)
if: runner.os == 'macOS'
run: brew install pigz
-
+
- name: Extract OpenVINO packages (Linux, macOS)
if: runner.os != 'Windows'
run: |
@@ -138,15 +138,6 @@ jobs:
PYTORCH_TRACING_MODE: EXPORT
PARALLEL: ${{ runner.os == 'Windows' && ' ' || '-n logical'}}
- - name: PyTorch torch.compile TORCHFX Layer Tests
- if: ${{ fromJSON(inputs.affected-components).PyTorch_FE.test && runner.os != 'macOS' && runner.arch != 'ARM64' && runner.os != 'Windows' }} # Ticket: 126287
- run: |
- python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/pytorch_tests -m precommit_fx_backend -v --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-pytorch_compile.xml
- env:
- TEST_DEVICE: CPU
- TEST_PRECISION: FP32
- PYTORCH_TRACING_MODE: TORCHFX
-
- name: Upload Test Results
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: ${{ !cancelled() }}
diff --git a/.github/workflows/linux_arm64.yml b/.github/workflows/linux_arm64.yml
index 3dc06e022c7..a2d63e40576 100644
--- a/.github/workflows/linux_arm64.yml
+++ b/.github/workflows/linux_arm64.yml
@@ -219,6 +219,16 @@ jobs:
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
python-version: '3.11'
+ Pytorch_FX_Layer_Tests:
+ name: Pytorch FX Layer Tests
+ needs: [ Build, Docker, Smart_CI ]
+ uses: ./.github/workflows/job_pytorch_fx_layer_tests.yml
+ with:
+ runner: 'aks-linux-16-cores-32gb-arm'
+ container: '{"image": "${{ fromJSON(needs.docker.outputs.images).ov_test.ubuntu_20_04_arm64 }}", "volumes": ["/mount:/mount"]}'
+ affected-components: ${{ needs.smart_ci.outputs.affected_components }}
+ python-version: '3.11'
+
JAX_Layer_Tests:
name: JAX Layer Tests
needs: [ Build, Docker, Smart_CI ]
diff --git a/.github/workflows/mac_arm64.yml b/.github/workflows/mac_arm64.yml
index f6ffe42a3d9..8e2dfd4e3c9 100644
--- a/.github/workflows/mac_arm64.yml
+++ b/.github/workflows/mac_arm64.yml
@@ -222,10 +222,10 @@ jobs:
- name: Build additional Python wheels
run: |
for py_version in "3.9" "3.10" "3.11" "3.12"
- do
+ do
python_exec_path=$(python$py_version -c "import sys; print(sys.executable)")
$python_exec_path -m pip install -r ${{ env.OPENVINO_REPO }}/src/bindings/python/wheel/requirements-dev.txt
-
+
cmake -DPython3_EXECUTABLE=$python_exec_path -DENABLE_WHEEL=ON -DOpenVINODeveloperPackage_DIR=${{ env.BUILD_DIR }} -S ${{ env.OPENVINO_REPO }}/src/bindings/python -B ${{ github.workspace }}/py$py_version
cmake --build ${{ github.workspace }}/py$py_version --parallel
cmake --install ${{ github.workspace }}/py$py_version --config ${{ env.CMAKE_BUILD_TYPE }} --prefix ${{ env.INSTALL_WHEELS_DIR }} --component python_wheels
@@ -282,7 +282,7 @@ jobs:
name: openvino_package
path: ${{ env.BUILD_DIR }}/openvino_package.tar.gz
if-no-files-found: 'error'
-
+
- name: Upload OpenVINO wheels
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
@@ -390,6 +390,15 @@ jobs:
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
python-version: '3.11'
+ Pytorch_FX_Layer_Tests:
+ name: Pytorch FX Layer Tests
+ needs: [ Build, Smart_CI ]
+ uses: ./.github/workflows/job_pytorch_fx_layer_tests.yml
+ with:
+ runner: 'macos-13-xlarge'
+ affected-components: ${{ needs.smart_ci.outputs.affected_components }}
+ python-version: '3.11'
+
JAX_Layer_Tests:
name: JAX Layer Tests
needs: [ Build, Smart_CI ]
diff --git a/.github/workflows/ubuntu_22.yml b/.github/workflows/ubuntu_22.yml
index de53813b177..d22dc6c3822 100644
--- a/.github/workflows/ubuntu_22.yml
+++ b/.github/workflows/ubuntu_22.yml
@@ -349,6 +349,16 @@ jobs:
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
python-version: '3.11'
+ Pytorch_FX_Layer_Tests:
+ name: Pytorch FX Layer Tests
+ needs: [ Docker, Build, Smart_CI ]
+ uses: ./.github/workflows/job_pytorch_fx_layer_tests.yml
+ with:
+ runner: 'aks-linux-4-cores-16gb'
+ container: '{"image": "${{ fromJSON(needs.docker.outputs.images).ov_test.ubuntu_22_04_x64 }}", "volumes": ["/mount:/mount"], "options": "-e HF_TOKEN"}'
+ affected-components: ${{ needs.smart_ci.outputs.affected_components }}
+ python-version: '3.11'
+
JAX_Layer_Tests:
name: JAX Layer Tests
needs: [ Docker, Build, Smart_CI ]
@@ -542,7 +552,7 @@ jobs:
steps:
- name: GPU stub
run: |
- echo "This is only a stub to collect statistics of GPU runs filtered by Smart CI.
+ echo "This is only a stub to collect statistics of GPU runs filtered by Smart CI.
It will help us to estimate hardware requirements"
shell: bash
diff --git a/.github/workflows/ubuntu_24.yml b/.github/workflows/ubuntu_24.yml
index f8a67ea55f8..49a206cc014 100644
--- a/.github/workflows/ubuntu_24.yml
+++ b/.github/workflows/ubuntu_24.yml
@@ -102,7 +102,7 @@ jobs:
build-contrib: true
build-additional-python-packages: true
target-branch: ${{ inputs.target-branch }}
- cmake-options: >-
+ cmake-options: >-
-G 'Ninja Multi-Config'
-DENABLE_CPPLINT=OFF
-DENABLE_NCC_STYLE=OFF
@@ -171,6 +171,16 @@ jobs:
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
python-version: '3.12'
+ Pytorch_FX_Layer_Tests:
+ name: Pytorch FX Layer Tests
+ needs: [ Docker, Build, Smart_CI ]
+ uses: ./.github/workflows/job_pytorch_fx_layer_tests.yml
+ with:
+ runner: 'aks-linux-4-cores-16gb'
+ container: '{"image": "${{ fromJSON(needs.docker.outputs.images).ov_test.ubuntu_24_04_x64 }}", "volumes": ["/mount:/mount"], "options": "-e HF_TOKEN"}'
+ affected-components: ${{ needs.smart_ci.outputs.affected_components }}
+ python-version: '3.12'
+
JAX_Layer_Tests:
name: JAX Layer Tests
needs: [ Docker, Build, Smart_CI ]
diff --git a/.github/workflows/windows_vs2022_release.yml b/.github/workflows/windows_vs2022_release.yml
index cf4ae69dea6..f0c4c48e6d5 100644
--- a/.github/workflows/windows_vs2022_release.yml
+++ b/.github/workflows/windows_vs2022_release.yml
@@ -506,6 +506,15 @@ jobs:
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
python-version: '3.11'
+ Pytorch_FX_Layer_Tests:
+ name: Pytorch FX Layer Tests
+ needs: [ Build, Smart_CI ]
+ uses: ./.github/workflows/job_pytorch_fx_layer_tests.yml
+ with:
+ runner: 'aks-win-8-cores-16gb'
+ affected-components: ${{ needs.smart_ci.outputs.affected_components }}
+ python-version: '3.11'
+
JAX_Layer_Tests:
name: JAX Layer Tests
needs: [ Build, Smart_CI ]
diff --git a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/backend.py b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/backend.py
index b44566b27c5..7e1ff5d8316 100644
--- a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/backend.py
+++ b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/backend.py
@@ -105,8 +105,9 @@ def fx_openvino(subgraph, example_inputs, options=None):
from torch._subclasses.fake_tensor import FakeTensorMode
decompositions = _get_decompositions(options) + get_inf_decomposition_list()
- with FakeTensorMode(allow_non_fake_inputs=True):
- model = make_fx(subgraph, decomposition_table=get_decompositions(decompositions))(*example_inputs)
+ with FakeTensorMode(allow_non_fake_inputs=True) as fakemode:
+ fake_inputs = [fakemode.from_tensor(x) for x in example_inputs]
+ model = make_fx(subgraph, decomposition_table=get_decompositions(decompositions))(*fake_inputs)
with torch.no_grad():
model.eval()
diff --git a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/op_support.py b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/op_support.py
index 750ac16f2ac..11576cac8e4 100644
--- a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/op_support.py
+++ b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/op_support.py
@@ -48,6 +48,7 @@ class OperatorSupport(OpSupport):
"torch.ops.aten._to_copy.default": None,
"torch.ops.aten._unsafe_view.default": None,
"torch.ops.aten.abs.default": None,
+ "torch.ops.aten.absolute.default": None,
"torch.ops.aten.acos.default": None,
"torch.ops.aten.acosh.default": None,
"torch.ops.aten.adaptive_max_pool1d.default": None,
@@ -144,6 +145,7 @@ class OperatorSupport(OpSupport):
"torch.ops.aten._unsafe_index.Tensor": None,
"torch.ops.aten.index_select.default": None,
"torch.ops.aten.index_copy.default": None,
+ "torch.ops.aten.index_put.default": None,
"torch.ops.aten.isfinite.default": None,
"torch.ops.aten.isinf.default": None,
"torch.ops.aten.isnan.default": None,
@@ -197,6 +199,8 @@ class OperatorSupport(OpSupport):
"torch.ops.aten.pow.Scalar": None,
"torch.ops.aten.pow.Tensor_Scalar": None,
"torch.ops.aten.pow.Tensor_Tensor": None,
+ "torch.ops.aten.prod.default": None,
+ "torch.ops.aten.prod.dim_int": None,
"torch.ops.aten.rand.default": None,
"torch.ops.aten.reflection_pad2d.default": None,
"torch.ops.aten.reciprocal.default": None,
@@ -250,6 +254,8 @@ class OperatorSupport(OpSupport):
"torch.ops.aten.unsqueeze.default": None,
"torch.ops.aten.unsqueeze_copy.default": None,
"torch.ops.aten.upsample_nearest2d.default": None,
+ "torch.ops.aten.upsample_nearest2d.vec": None,
+ "torch.ops.aten.upsample_nearest3d.vec": None,
"torch.ops.aten.var.correction": None,
"torch.ops.aten.var_mean.correction": None,
"torch.ops.aten.view.default": None,
@@ -258,6 +264,7 @@ class OperatorSupport(OpSupport):
"torch.ops.aten.zero.default": None,
"torch.ops.aten.zeros.default": None,
"torch.ops.aten.zeros_like.default": None,
+ "torch.ops.scalar_tensor.default": None,
"torch.ops.torchvision.deform_conv2d.default": None,
"torch.ops.torchvision.roi_align.default": None,
"torch.ops.quantized_decomposed.quantize_per_tensor.default": None,
diff --git a/src/frontends/pytorch/src/op/prod.cpp b/src/frontends/pytorch/src/op/prod.cpp
index bdd81b9a511..37e9f31d8bb 100644
--- a/src/frontends/pytorch/src/op/prod.cpp
+++ b/src/frontends/pytorch/src/op/prod.cpp
@@ -11,6 +11,25 @@ namespace frontend {
namespace pytorch {
namespace op {
+using namespace ov::op;
+
+Output<Node> translate_prod_common(const NodeContext& context,
+ const Output<Node>& input,
+ const Output<Node>& dim,
+ bool keepdim,
+ bool skip_bool_check) {
+ // ReduceProd doesn't support boolean inputs
+ auto input_tensor = input;
+ if (!skip_bool_check) {
+ auto data_dtype = simplified_type_interpret(context.get_input_type(0));
+ if (input_tensor.get_element_type() == element::boolean ||
+ (data_dtype.is<element::Type>() && data_dtype.as<element::Type>() == element::boolean)) {
+ input_tensor = context.mark_node(std::make_shared<ov::op::v0::Convert>(input_tensor, element::i64));
+ }
+ }
+ return context.mark_node(std::make_shared<ov::op::v1::ReduceProd>(input_tensor, dim, keepdim));
+}
+
OutputVector translate_prod(const NodeContext& context) {
// aten::prod.dim_int(Tensor self, int dim, bool keepdim=False, *, ScalarType? dtype=None) -> Tensor
// aten::prod(Tensor self, *, ScalarType? dtype=None) -> Tensor
@@ -30,19 +49,40 @@ OutputVector translate_prod(const NodeContext& context) {
} else {
FRONT_END_GENERAL_CHECK(false, "Unexpected number of inputs.");
}
+ bool skip_bool_check = false;
if (!context.input_is_none(dtype_idx)) {
+ skip_bool_check = true;
input = apply_dtype(context, dtype_idx, input);
+ }
+ auto prod = translate_prod_common(context, input, dim, keepdim, skip_bool_check);
+ return {prod};
+};
+
+OutputVector translate_prod_fx(const NodeContext& context) {
+ // aten.prod.dim_int(Tensor self, int dim, bool keepdim=False, *, ScalarType? dtype=None) -> Tensor
+ // aten.prod(Tensor self, *, ScalarType? dtype=None) -> Tensor
+
+ num_inputs_check(context, 1, 3);
+ auto input = context.get_input(0);
+ bool keepdim = false;
+ Output<Node> dim;
+ if (!context.input_is_none(1)) {
+ dim = context.get_input(1);
} else {
- // ReduceProd doesn't support boolean inputs
- auto data_dtype = simplified_type_interpret(context.get_input_type(0));
- if (input.get_element_type() == element::boolean ||
- (data_dtype.is<element::Type>() && data_dtype.as<element::Type>() == element::boolean)) {
- input = context.mark_node(std::make_shared<ov::op::v0::Convert>(input, element::i64));
- }
+ dim = get_axes_range(context, 0);
+ }
+ if (!context.input_is_none(2)) {
+ keepdim = context.const_input<bool>(2);
}
- Output<Node> prod = context.mark_node(std::make_shared<ov::op::v1::ReduceProd>(input, dim, keepdim));
+ bool skip_bool_check = false;
+ if (context.has_attribute("dtype")) {
+ skip_bool_check = true;
+ auto dtype = context.get_attribute<element::Type>("dtype");
+ input = context.mark_node(std::make_shared<ov::op::v0::Convert>(input, dtype));
+ }
+ auto prod = translate_prod_common(context, input, dim, keepdim, skip_bool_check);
return {prod};
-}
+};
} // namespace op
} // namespace pytorch
diff --git a/src/frontends/pytorch/src/op_table.cpp b/src/frontends/pytorch/src/op_table.cpp
index a3c20a46434..89fd27dce9a 100644
--- a/src/frontends/pytorch/src/op_table.cpp
+++ b/src/frontends/pytorch/src/op_table.cpp
@@ -327,6 +327,7 @@ OP_CONVERTER(translate_new_ones_fx);
OP_CONVERTER(translate_new_zeros_fx);
OP_CONVERTER(translate_ones_fx);
OP_CONVERTER(translate_ones_like_fx);
+OP_CONVERTER(translate_prod_fx);
OP_CONVERTER(translate_reflection_pad_nd_fx);
OP_CONVERTER(translate_repeat_fx);
OP_CONVERTER(translate_rsub_fx);
@@ -388,6 +389,8 @@ const std::unordered_map<std::string, CreatorFunction> get_supported_ops_ts() {
{"aten::_weight_norm", op::translate_weight_norm},
{"aten::abs", op::optional_out<op::translate_abs, 1>},
{"aten::abs_", op::inplace_op<op::translate_abs>},
+ {"aten::absolute", op::optional_out<op::translate_abs, 1>},
+ {"aten::absolute_", op::inplace_op<op::translate_abs>},
{"aten::acos", op::optional_out<op::translate_1to1_match_1_inputs_with_fp32_type_alignment<opset10::Acos>, 1>},
{"aten::acos_", op::inplace_op<op::translate_1to1_match_1_inputs<opset10::Acos>>},
{"aten::acosh",
@@ -833,6 +836,7 @@ const std::unordered_map<std::string, CreatorFunction> get_supported_ops_fx() {
{"aten._to_copy.default", op::translate_to_fx},
{"aten._unsafe_view.default", op::translate_reshape},
{"aten.abs.default", op::translate_1to1_match_1_inputs<opset10::Abs>},
+ {"aten.absolute.default", op::translate_1to1_match_1_inputs<opset10::Abs>},
{"aten.acos.default", op::translate_1to1_match_1_inputs_with_fp32_type_alignment<opset10::Acos>},
{"aten.acosh.default", op::translate_1to1_match_1_inputs_with_fp32_type_alignment<opset10::Acosh>},
{"aten.adaptive_max_pool1d.default", op::translate_adaptive_max_pool1d_fx},
@@ -945,6 +949,7 @@ const std::unordered_map<std::string, CreatorFunction> get_supported_ops_fx() {
{"aten._unsafe_index.Tensor", op::translate_index_fx},
{"aten.index_select.default", op::translate_index_select},
{"aten.index_copy.default", op::translate_index_copy_},
+ {"aten.index_put.default", op::translate_index_put},
{"aten.isfinite.default", op::translate_1to1_match_1_inputs<opset10::IsFinite>},
{"aten.isinf.default", op::translate_1to1_match_1_inputs<opset10::IsInf>},
{"aten.isnan.default", op::translate_1to1_match_1_inputs<opset10::IsNaN>},
@@ -1004,6 +1009,8 @@ const std::unordered_map<std::string, CreatorFunction> get_supported_ops_fx() {
{"aten.pow.Tensor_Tensor", op::translate_pow},
{"aten.pixel_shuffle.default", op::translate_pixel_shuffle},
{"aten.pixel_unshuffle.default", op::translate_pixel_unshuffle},
+ {"aten.prod.default", op::translate_prod_fx},
+ {"aten.prod.dim_int", op::translate_prod_fx},
{"aten.rand.default", op::translate_rand},
{"aten.reciprocal.default", op::translate_reciprocal},
{"aten.reflection_pad1d.default", op::translate_reflection_pad_nd_fx},
@@ -1083,6 +1090,7 @@ const std::unordered_map<std::string, CreatorFunction> get_supported_ops_fx() {
{"aten.zeros.names", op::translate_zeros_fx},
{"aten.zeros_like.default", op::translate_zeros_like_fx},
{"get_attr", op::translate_constant},
+ {"scalar_tensor.default", op::translate_scalar_tensor_fx},
{"torchvision.deform_conv2d.default", op::translate_deform_conv},
{"torchvision.roi_align.default", op::translate_roi_align},
{"quantized_decomposed.quantize_per_tensor.default", op::translate_quantize_per_tensor_fx},
diff --git a/src/frontends/pytorch/src/transforms/aten_index_put_replacer.cpp b/src/frontends/pytorch/src/transforms/aten_index_put_replacer.cpp
index 251a3498629..20f61c14731 100644
--- a/src/frontends/pytorch/src/transforms/aten_index_put_replacer.cpp
+++ b/src/frontends/pytorch/src/transforms/aten_index_put_replacer.cpp
@@ -122,6 +122,18 @@ AtenIndexPutReplacer::AtenIndexPutReplacer() {
}
}
+ // In some exported graphs, when index_put_ is used with None indices, shape of values
+ // might be missing the first dimension of 1. For example, a value shape can be provided
+ // as (x,y,z) instead of (1,x,y,z). Both cases are valid for aten.index_put_.default.
+ auto input_rank = input.get_partial_shape().rank();
+ auto values_rank = values.get_partial_shape().rank();
+ if (static_cast<int64_t>(dims_with_none_idx.size()) > 0 && input_rank.is_static() && values_rank.is_static() &&
+ input_rank.get_length() > 1 && input_rank.get_length() == values_rank.get_length() + 1 &&
+ static_cast<int64_t>(dims_with_none_idx.size()) == indices_list_len - 1 &&
+ !(is_none_node(indices_inputs[indices_list_len - 1]))) {
+ values = rg.make<v0::Unsqueeze>(values, const_0);
+ }
+
std::vector<int64_t> perm_vector_before;
std::vector<int64_t> perm_vector_after;
if (static_cast<int64_t>(dims_with_none_idx.size()) == indices_list_len) {
diff --git a/tests/layer_tests/pytorch_tests/test_add.py b/tests/layer_tests/pytorch_tests/test_add.py
index 4212cda9d8d..7b3e525fa55 100644
--- a/tests/layer_tests/pytorch_tests/test_add.py
+++ b/tests/layer_tests/pytorch_tests/test_add.py
@@ -5,7 +5,7 @@ import numpy as np
import pytest
import torch
-from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
+from pytorch_layer_test_class import PytorchLayerTest, skip_check
@pytest.mark.parametrize('alpha', (-0.5, 0, 0.5, 1, 2))
@@ -41,7 +41,7 @@ class TestAdd(PytorchLayerTest):
@pytest.mark.precommit
@pytest.mark.precommit_torch_export
@pytest.mark.precommit_fx_backend
- @pytest.mark.parametrize("op_type", ["add", skip_if_export("add_")])
+ @pytest.mark.parametrize("op_type", ["add", skip_check("add_")])
def test_add(self, ie_device, precision, ir_version, alpha, input_shape_rhs, op_type):
self.input_rhs = np.random.randn(*input_shape_rhs).astype(np.float32)
self._test(*self.create_model(alpha, op_type), ie_device, precision, ir_version, use_convert_model=True)
diff --git a/tests/layer_tests/pytorch_tests/test_index_put_.py b/tests/layer_tests/pytorch_tests/test_index_put_.py
index 761217c7be7..1d46c74f6a4 100644
--- a/tests/layer_tests/pytorch_tests/test_index_put_.py
+++ b/tests/layer_tests/pytorch_tests/test_index_put_.py
@@ -112,6 +112,50 @@ class TestIndexPut_ManyIndices(PytorchLayerTest):
self._test(*self.create_model(indices, accumulate), ie_device, precision, ir_version)
+class TestIndexPut_ManyIndicesWithNone(PytorchLayerTest):
+ def _prepare_input(self):
+ return (self.input_tensor, self.values)
+
+ def create_model(self, indices, accumulate):
+ class aten_index_put_(torch.nn.Module):
+ def __init__(self, indices, accumulate):
+ super().__init__()
+ self.indices_first = indices[0]
+ self.indices_second = indices[1]
+ self.indices_third = indices[2]
+ self.accumulate = accumulate
+
+ def forward(self, input_tensor, values):
+ return torch.ops.aten.index_put_.default(input_tensor, (self.indices_first, self.indices_second, self.indices_third), values, self.accumulate)
+
+ ref_net = None
+
+ return aten_index_put_(indices, accumulate), ref_net, "aten::index_put_"
+
+ @pytest.mark.parametrize(
+ "input_data",
+ (
+ {
+ "input_shape": [1, 8, 8, 8],
+ "values": np.ones((8,1,8)).astype(np.float32)
+ },
+ ),
+ )
+ @pytest.mark.parametrize(
+ "indices",
+ (
+ (None, None, torch.tensor([0], dtype=torch.long)),
+ ),
+ )
+ @pytest.mark.parametrize("accumulate", (True, False))
+ @pytest.mark.precommit_torch_export
+ @pytest.mark.precommit_fx_backend
+ def test_index_put_many_indices_with_none(self, ie_device, precision, ir_version, input_data, indices, accumulate):
+ self.input_tensor = np.zeros(input_data["input_shape"]).astype(np.float32)
+ self.values = input_data["values"]
+ self._test(*self.create_model(indices, accumulate), ie_device, precision, ir_version, aot_autograd=True)
+
+
class TestNonZero_IndexPut(PytorchLayerTest):
def _prepare_input(self):
return (self.input_tensor, self.values, self.indices_0, self.indices_1)
diff --git a/tests/layer_tests/pytorch_tests/test_leaky_relu.py b/tests/layer_tests/pytorch_tests/test_leaky_relu.py
index 338e989f9b1..43b4cc334b6 100644
--- a/tests/layer_tests/pytorch_tests/test_leaky_relu.py
+++ b/tests/layer_tests/pytorch_tests/test_leaky_relu.py
@@ -3,7 +3,7 @@
import pytest
-from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
+from pytorch_layer_test_class import PytorchLayerTest, skip_check
class TestLeakyRelu(PytorchLayerTest):
@@ -29,7 +29,7 @@ class TestLeakyRelu(PytorchLayerTest):
return aten_leaky_relu(alpha, inplace), ref_net, "aten::leaky_relu" if not inplace else "aten::leaky_relu_"
@pytest.mark.parametrize("alpha", [0.01, 1.01, -0.01])
- @pytest.mark.parametrize("inplace", [skip_if_export(True), False])
+ @pytest.mark.parametrize("inplace", [skip_check(True), False])
@pytest.mark.nightly
@pytest.mark.precommit
@pytest.mark.precommit_torch_export
diff --git a/tests/layer_tests/pytorch_tests/test_prod.py b/tests/layer_tests/pytorch_tests/test_prod.py
index 79df818fc38..26d2ac665ae 100644
--- a/tests/layer_tests/pytorch_tests/test_prod.py
+++ b/tests/layer_tests/pytorch_tests/test_prod.py
@@ -52,7 +52,6 @@ class aten_prod_dim_dtype(torch.nn.Module):
class TestProd(PytorchLayerTest):
def _prepare_input(self, input_shape=(2), dtype=torch.float32):
- import numpy as np
return (torch.randn(*input_shape).to(dtype).numpy(),)
@pytest.mark.parametrize("shape", [(1,),
@@ -66,6 +65,8 @@ class TestProd(PytorchLayerTest):
@pytest.mark.parametrize("has_dim,keepdims", [(False, None), (True, True), (True, False)])
@pytest.mark.nightly
@pytest.mark.precommit
+ @pytest.mark.precommit_torch_export
+ @pytest.mark.precommit_fx_backend
def test_prod(self, ie_device, precision, ir_version, shape, dtype, in_dtype, has_dim, keepdims):
if dtype is not None:
if has_dim:
diff --git a/tests/layer_tests/pytorch_tests/test_scalar_tensor.py b/tests/layer_tests/pytorch_tests/test_scalar_tensor.py
new file mode 100644
index 00000000000..be3a6ec1289
--- /dev/null
+++ b/tests/layer_tests/pytorch_tests/test_scalar_tensor.py
@@ -0,0 +1,34 @@
+# Copyright (C) 2018-2025 Intel Corporation
+# SPDX-License-Identifier: Apache-2.0
+
+import numpy as np
+import pytest
+import torch
+
+from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
+
+
+class TestScalarTensor(PytorchLayerTest):
+
+ def _prepare_input(self):
+ return (np.array(np.random.randn(), dtype=np.float32),)
+
+ def create_model(self):
+ class aten_scalar_tensor(torch.nn.Module):
+
+ def __init__(self) -> None:
+ super().__init__()
+
+ def forward(self, lhs):
+ return torch.scalar_tensor(lhs.item())
+
+ ref_net = None
+
+ return aten_scalar_tensor(), ref_net, f"aten::scalar_tensor"
+
+ @pytest.mark.precommit_torch_export
+ @pytest.mark.precommit_fx_backend
+ def test_scalar_tensor(self, ie_device, precision, ir_version):
+ self._test(*self.create_model(), ie_device, precision, ir_version, use_convert_model=True)
+
+
diff --git a/tests/layer_tests/pytorch_tests/test_unary_ops.py b/tests/layer_tests/pytorch_tests/test_unary_ops.py
index 03a6d534574..33297b81a25 100644
--- a/tests/layer_tests/pytorch_tests/test_unary_ops.py
+++ b/tests/layer_tests/pytorch_tests/test_unary_ops.py
@@ -230,6 +230,8 @@ class TestUnaryOp(PytorchLayerTest):
])
def test_unary_op_float(self, op_type, dtype, ie_device, precision, ir_version):
self.dtype = dtype
+ if self.use_torch_compile_backend() and op_type == "aten::sigmoid_":
+ pytest.xfail(reason="Accuracy issue, one or two values are off sometimes")
self._test(unary_op_net(OPS[op_type], dtype), None, op_type,
ie_device, precision, ir_version)
@@ -275,7 +277,6 @@ class TestUnaryOp(PytorchLayerTest):
@pytest.mark.nightly
@pytest.mark.precommit
- @pytest.mark.precommit_fx_backend
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
@pytest.mark.parametrize("op_type",
[
diff --git a/tests/layer_tests/pytorch_tests/test_upsample.py b/tests/layer_tests/pytorch_tests/test_upsample.py
index 374889e4762..eac0ec21e4d 100644
--- a/tests/layer_tests/pytorch_tests/test_upsample.py
+++ b/tests/layer_tests/pytorch_tests/test_upsample.py
@@ -186,6 +186,8 @@ class TestUpsample3D(PytorchLayerTest):
])
@pytest.mark.nightly
@pytest.mark.precommit
+ @pytest.mark.precommit_torch_export
+ @pytest.mark.precommit_fx_backend
def test_upsample3d(self, mode, size, scale, ie_device, precision, ir_version):
self._test(*self.create_model(size, scale, mode), ie_device,
precision, ir_version, trace_model=True, **{"custom_eps": 1e-3})