-
Notifications
You must be signed in to change notification settings - Fork 609
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganize plugins to reflect actual module hierarchy
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com> WIP Signed-off-by: Krzysztof Lecki <klecki@nvidia.com> WIP Continue with numba function Signed-off-by: Krzysztof Lecki <klecki@nvidia.com> Numba and python Signed-off-by: Krzysztof Lecki <klecki@nvidia.com> Torch Python Functon Signed-off-by: Krzysztof Lecki <klecki@nvidia.com> Move annotations around Signed-off-by: Krzysztof Lecki <klecki@nvidia.com> Minor revisions Signed-off-by: Krzysztof Lecki <klecki@nvidia.com> Write tests for pytorch, extend TorchFunction overload Fixup the None return in Python Functions (Sequence doesn't count here). Signed-off-by: Krzysztof Lecki <klecki@nvidia.com> Adjust the type of required return type in the PythonFunction callback Signed-off-by: Krzysztof Lecki <klecki@nvidia.com> Extend tests Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
- Loading branch information
Showing
13 changed files
with
443 additions
and
97 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
67 changes: 67 additions & 0 deletions
67
dali/python/nvidia/dali/plugin/numba/experimental/__init__.pyi
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,67 @@ | ||
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. 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. | ||
|
||
from typing import Any, Optional, Union, List, Sequence, Callable | ||
|
||
from nvidia.dali.data_node import DataNode | ||
|
||
from nvidia.dali.types import DALIDataType | ||
|
||
class NumbaFunction: | ||
"""Invokes a njit compiled Numba function. | ||
The run function should be a Python function that can be compiled in Numba ``nopython`` mode.""" | ||
|
||
def __init__( | ||
self, | ||
run_fn: Optional[Callable[..., None]] = None, | ||
out_types: Optional[List[DALIDataType]] = None, | ||
in_types: Optional[List[DALIDataType]] = None, | ||
outs_ndim: Optional[List[int]] = None, | ||
ins_ndim: Optional[List[int]] = None, | ||
setup_fn: Optional[ | ||
Callable[[Sequence[Sequence[Any]], Sequence[Sequence[Any]], None]] | ||
] = None, | ||
device: str = "cpu", | ||
batch_processing: bool = False, | ||
blocks: Optional[Sequence[int]] = None, | ||
threads_per_block: Optional[Sequence[int]] = None, | ||
bytes_per_sample_hint: Union[Sequence[int], int, None] = [0], | ||
seed: Optional[int] = -1, | ||
) -> None: ... | ||
def __call__( | ||
self, | ||
__input_0: DataNode, | ||
__input_1: Optional[DataNode] = None, | ||
__input_2: Optional[DataNode] = None, | ||
__input_3: Optional[DataNode] = None, | ||
__input_4: Optional[DataNode] = None, | ||
__input_5: Optional[DataNode] = None, | ||
/, | ||
*, | ||
run_fn: Optional[Callable[..., None]] = None, | ||
out_types: Optional[List[DALIDataType]] = None, | ||
in_types: Optional[List[DALIDataType]] = None, | ||
outs_ndim: Optional[List[int]] = None, | ||
ins_ndim: Optional[List[int]] = None, | ||
setup_fn: Optional[ | ||
Callable[[Sequence[Sequence[Any]], Sequence[Sequence[Any]], None]] | ||
] = None, | ||
device: str = "cpu", | ||
batch_processing: bool = False, | ||
blocks: Optional[Sequence[int]] = None, | ||
threads_per_block: Optional[Sequence[int]] = None, | ||
bytes_per_sample_hint: Union[Sequence[int], int, None] = [0], | ||
seed: Optional[int] = -1, | ||
) -> Union[DataNode, Sequence[DataNode]]: ... |
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,15 @@ | ||
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. 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. | ||
|
||
from . import experimental # noqa F401 |
13 changes: 13 additions & 0 deletions
13
dali/python/nvidia/dali/plugin/numba/fn/experimental/__init__.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,13 @@ | ||
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. 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. |
48 changes: 48 additions & 0 deletions
48
dali/python/nvidia/dali/plugin/numba/fn/experimental/__init__.pyi
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,48 @@ | ||
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. 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. | ||
|
||
from typing import Any, Optional, Union, List, Sequence, Callable | ||
|
||
from nvidia.dali.data_node import DataNode | ||
|
||
from nvidia.dali.types import DALIDataType | ||
|
||
def numba_function( | ||
__input_0: DataNode, | ||
__input_1: Optional[DataNode] = None, | ||
__input_2: Optional[DataNode] = None, | ||
__input_3: Optional[DataNode] = None, | ||
__input_4: Optional[DataNode] = None, | ||
__input_5: Optional[DataNode] = None, | ||
/, | ||
*, | ||
run_fn: Callable[..., None], | ||
out_types: List[DALIDataType], | ||
in_types: List[DALIDataType], | ||
outs_ndim: List[int], | ||
ins_ndim: List[int], | ||
setup_fn: Optional[Callable[[Sequence[Sequence[Any]], Sequence[Sequence[Any]], None]]] = None, | ||
batch_processing: bool = False, | ||
blocks: Optional[Sequence[int]] = None, | ||
threads_per_block: Optional[Sequence[int]] = None, | ||
bytes_per_sample_hint: Union[Sequence[int], int, None] = [0], | ||
preserve: Optional[bool] = False, | ||
seed: Optional[int] = -1, | ||
device: Optional[str] = None, | ||
name: Optional[str] = None, | ||
) -> Union[DataNode, Sequence[DataNode]]: | ||
"""Invokes a njit compiled Numba function. | ||
The run function should be a Python function that can be compiled in Numba ``nopython`` mode.""" | ||
... |
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
Oops, something went wrong.