コード例 #1
0
ファイル: logging.py プロジェクト: astralblue/jirax
 def __get_logger(self):
     try:
         return getattr(tls(), self.__logger_name)
     except AttributeError:
         if self.__default_logger is not None:
             return self.__default_logger
         else:
             return logging.getLogger()
コード例 #2
0
ファイル: pipeline.py プロジェクト: tomzhang/DALI
#
# 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.

#pylint: disable=no-member
from collections import deque
from nvidia.dali import backend as b
from nvidia.dali import tensors as Tensors
from nvidia.dali import types
from threading import local as tls
from . import data_node as _data_node
import warnings
pipeline_tls = tls()

from .data_node import DataNode
DataNode.__module__ = __name__  # move to pipeline


def _show_deprecation_warning(deprecated, in_favor_of):
    # show only this warning
    with warnings.catch_warnings():
        warnings.simplefilter("default")
        warnings.warn("{} is deprecated, please use {} instead".format(
            deprecated, in_favor_of),
                      Warning,
                      stacklevel=2)

コード例 #3
0
from abc import ABC, abstractmethod
from numba.core.registry import TargetRegistry, CPUDispatcher

from threading import local as tls

_active_context = tls()
_active_context_default = 'cpu'


class HardwareRegistry(TargetRegistry):

    def __getitem__(self, item):
        try:
            return super().__getitem__(item)
        except KeyError:
            msg = "No target is registered against '{}', known targets:\n{}"
            known = '\n'.join([f"{k: <{10}} -> {v}"
                               for k, v in hardware_registry.items()])
            raise ValueError(msg.format(item, known)) from None


hardware_registry = HardwareRegistry()


class hardware_target(object):
    def __init__(self, name):
        self._orig_target = getattr(_active_context, 'target',
                                    _active_context_default)
        self.target = name

    def __enter__(self):