Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dummy interfaces for import timm #10395

Merged
merged 3 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions python/oneflow/ao/quantization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
Copyright 2020 The OneFlow Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""


class DeQuantStub:
def __init__(self, *args, **kwargs):
raise NotImplementedError(
"The oneflow.ao.DeQuantStub interface is just to align the torch.ao.DeQuantStub interface and has no practical significance."
)


class QuantStub:
def __init__(self, *args, **kwargs):
raise NotImplementedError(
"The oneflow.ao.QuantStub interface is just to align the torch.ao.QuantStub interface and has no practical significance."
)
70 changes: 70 additions & 0 deletions python/oneflow/jit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
import warnings
from typing import Any, Dict, List, Set, Tuple, Union, Callable

warnings.warn(
"The oneflow.jit interface is just to align the torch.jit interface and has no practical significance."
)


def script(
obj,
Expand Down Expand Up @@ -71,3 +75,69 @@ def is_scripting():

def is_tracing():
return False


class _Final:
"""Mixin to prohibit subclassing"""

__slots__ = ("__weakref__",)

def __init_subclass__(self, /, *args, **kwds):
if "_root" not in kwds:
raise TypeError("Cannot subclass special typing classes")


class _SpecialForm(_Final, _root=True):
__slots__ = ("_name", "__doc__", "_getitem")

def __init__(self, getitem):
self._getitem = getitem
self._name = getitem.__name__
self.__doc__ = getitem.__doc__

def __getattr__(self, item):
if item in {"__name__", "__qualname__"}:
return self._name

raise AttributeError(item)

def __mro_entries__(self, bases):
raise TypeError(f"Cannot subclass {self!r}")

def __repr__(self):
return "typing." + self._name

def __reduce__(self):
return self._name

def __call__(self, *args, **kwds):
raise TypeError(f"Cannot instantiate {self!r}")

def __or__(self, other):
return Union[self, other]

def __ror__(self, other):
return Union[other, self]

def __instancecheck__(self, obj):
raise TypeError(f"{self} cannot be used with isinstance()")

def __subclasscheck__(self, cls):
raise TypeError(f"{self} cannot be used with issubclass()")

def __getitem__(self, parameters):
return self._getitem(self, parameters)


@_SpecialForm
def Final(*args, **kwargs):
warnings.warn(
"The oneflow.jit.Final interface is just to align the torch.jit.Final interface and has no practical significance."
)


def interface(fn):
warnings.warn(
"The oneflow.jit.interface interface is just to align the torch.jit.interface interface and has no practical significance."
)
return fn
2 changes: 1 addition & 1 deletion python/oneflow/jit/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
"""
from typing import Tuple
from typing import Tuple, List

BroadcastingList2 = Tuple
20 changes: 20 additions & 0 deletions python/oneflow/library.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
Copyright 2020 The OneFlow Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import warnings

warnings.warn(
"The oneflow.library interface is just to align the torch.library interface and has no practical significance."
)
28 changes: 28 additions & 0 deletions python/oneflow/onnx/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Copyright 2020 The OneFlow Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import warnings


def symbolic_opset11():
warnings.warn(
"The oneflow.onnx.symbolic_opset11 interface is just to align the torch.onnx.symbolic_opset11 interface and has no practical significance."
)


def register_custom_op_symbolic(*args, **kwargs):
warnings.warn(
"The oneflow.onnx.register_custom_op_symbolic interface is just to align the torch.onnx.register_custom_op_symbolic interface and has no practical significance."
)
28 changes: 28 additions & 0 deletions python/oneflow/onnx/symbolic_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Copyright 2020 The OneFlow Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import warnings


def parse_args(*args, **kwargs):
warnings.warn(
"The oneflow.onnx.parse_args interface is just to align the torch.onnx.parse_args interface and has no practical significance."
)

def func(fn):
return fn

return func
Loading