forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PT FE] Support prim::fork and aten::wait (openvinotoolkit#26839)
### Details: - *Support `prim::fork` and `aten::wait`* ### Tickets: - *CVS-153613* --------- Co-authored-by: Michal Lukaszewski <michal.lukaszewski@intel.com>
- Loading branch information
Showing
3 changed files
with
59 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright (C) 2018-2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import numpy as np | ||
import pytest | ||
import torch | ||
|
||
from pytorch_layer_test_class import PytorchLayerTest | ||
|
||
|
||
class TestForkWait(PytorchLayerTest): | ||
|
||
def _prepare_input(self): | ||
return (np.random.randn(10, 20),) | ||
|
||
def create_model(self): | ||
|
||
class AddMod(torch.nn.Module): | ||
def forward(self, a: torch.Tensor, b: int): | ||
return a + b, a - b | ||
|
||
class Mod(torch.nn.Module): | ||
def __init__(self): | ||
super().__init__() | ||
self.mod = AddMod() | ||
|
||
def forward(self, input): | ||
fut = torch.jit.fork(self.mod, a=input, b=2) | ||
return torch.jit.wait(fut) | ||
|
||
return Mod(), None, ["prim::fork", "aten::wait"] | ||
|
||
@pytest.mark.nightly | ||
@pytest.mark.precommit | ||
@pytest.mark.parametrize(("to_trace"), [True, False]) | ||
def test_fork_wait(self, to_trace, ie_device, precision, ir_version): | ||
self._test(*self.create_model(), ie_device, precision, | ||
ir_version, trace_model=to_trace) |