-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add(torch-frontend): Adds torchvision frontend and moves torch.ops.to…
…rchvision there (#26491)
- Loading branch information
Showing
12 changed files
with
183 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
"paddle": "2.5.1", | ||
"sklearn": "1.3.0", | ||
"xgboost": "1.7.6", | ||
"torchvision": "0.15.2.", | ||
} | ||
|
||
|
||
|
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,23 @@ | ||
import sys | ||
|
||
|
||
import ivy.functional.frontends.torch as torch | ||
import ivy | ||
from ivy.functional.frontends import set_frontend_to_specific_version | ||
|
||
|
||
from . import ops | ||
|
||
|
||
tensor = _frontend_array = torch.tensor | ||
|
||
|
||
# setting to specific version # | ||
# --------------------------- # | ||
|
||
if ivy.is_local(): | ||
module = ivy.utils._importlib.import_cache[__name__] | ||
else: | ||
module = sys.modules[__name__] | ||
|
||
set_frontend_to_specific_version(module) |
File renamed without changes.
145 changes: 145 additions & 0 deletions
145
ivy_tests/test_ivy/test_frontends/config/torchvision.py
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,145 @@ | ||
from .base import FrontendConfig, SupportedDtypes, SupportedDeviecs | ||
import ivy | ||
|
||
|
||
def get_config(): | ||
return TorchVisionFrontendConfig() | ||
|
||
|
||
class TorchVisionFrontendConfig(FrontendConfig): | ||
backend = ivy.with_backend("torch") | ||
|
||
valid_devices = ["cpu", "gpu"] | ||
invalid_devices = ["tpu"] | ||
|
||
valid_dtypes = [ | ||
"int16", | ||
"int32", | ||
"int64", | ||
"uint8", | ||
"float16", | ||
"float32", | ||
"float64", | ||
] | ||
|
||
invalid_dtypes = [ | ||
"int8", | ||
"uint16", | ||
"uint32", | ||
"uint64", | ||
"bfloat16", | ||
"complex64", | ||
"complex128", | ||
"bool", | ||
] | ||
|
||
valid_numeric_dtypes = [ | ||
"int16", | ||
"int32", | ||
"int64", | ||
"uint8", | ||
"float16", | ||
"float32", | ||
"float64", | ||
] | ||
|
||
invalid_numeric_dtypes = [ | ||
"int8", | ||
"uint16", | ||
"uint32", | ||
"uint64", | ||
"bfloat16", | ||
"complex64", | ||
"complex128", | ||
"bool", | ||
] | ||
|
||
valid_int_dtypes = [ | ||
"int16", | ||
"int32", | ||
"int64", | ||
"uint8", | ||
] | ||
|
||
invalid_int_dtypes = [ | ||
"int8", | ||
"uint16", | ||
"uint32", | ||
"uint64", | ||
] | ||
|
||
valid_uint_dtypes = [ | ||
"uint8", | ||
] | ||
|
||
invalid_uint_dtypes = [ | ||
"uint16", | ||
"uint32", | ||
"uint64", | ||
] | ||
|
||
valid_float_dtypes = [ | ||
"float16", | ||
"float32", | ||
"float64", | ||
] | ||
|
||
invalid_float_dtypes = [ | ||
"bfloat16", | ||
] | ||
|
||
valid_complex_dtypes = [] | ||
|
||
invalid_complex_dtypes = [ | ||
"complex64", | ||
"complex128", | ||
] | ||
|
||
@property | ||
def supported_devices(self): | ||
return SupportedDeviecs( | ||
valid_devices=self.valid_devices, invalid_devices=self.invalid_devices | ||
) | ||
|
||
@property | ||
def supported_dtypes(self): | ||
return SupportedDtypes( | ||
valid_dtypes=self.valid_dtypes, | ||
invalid_dtypes=self.invalid_dtypes, | ||
valid_numeric_dtypes=self.valid_numeric_dtypes, | ||
invalid_numeric_dtypes=self.invalid_numeric_dtypes, | ||
valid_int_dtypes=self.valid_int_dtypes, | ||
invalid_int_dtypes=self.invalid_int_dtypes, | ||
valid_uint_dtypes=self.valid_uint_dtypes, | ||
invalid_uint_dtypes=self.invalid_uint_dtypes, | ||
valid_float_dtypes=self.valid_float_dtypes, | ||
invalid_float_dtypes=self.invalid_float_dtypes, | ||
valid_complex_dtypes=self.valid_complex_dtypes, | ||
invalid_complex_dtypes=self.invalid_complex_dtypes, | ||
) | ||
|
||
@property | ||
def Dtype(self): | ||
return self.backend.Dtype | ||
|
||
@property | ||
def Device(self): | ||
return self.backend.Device | ||
|
||
def native_array(self, x): | ||
return self.backend.native_array(x) | ||
|
||
def is_native_array(self, x): | ||
return self.backend.is_native_array(x) | ||
|
||
def to_numpy(self, x): | ||
return self.backend.to_numpy(x) | ||
|
||
def as_native_dtype(self, dtype: str): | ||
return self.backend.as_native_dtype(dtype) | ||
|
||
def as_native_device(self, device: str): | ||
return self.backend.as_native_dev(device) | ||
|
||
def isscalar(self, x): | ||
return self.backend.isscalar(x) |
Empty file removed
0
ivy_tests/test_ivy/test_frontends/test_torch/test_ops/test_torchvision/__init__.py
Empty file.
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
ivy_tests/test_ivy/test_frontends/test_torchvision/conftest.py
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,6 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def frontend(): | ||
return "torchvision" |
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