Ejemplo n.º 1
0
    def __init__(self, thread_count=None):
        if thread_count is None:
            thread_count = 0

        if isinstance(thread_count, PythonWrapper.MathEngine):
            super().__init__(thread_count)
            return

        internal = PythonWrapper.MathEngine('cpu', int(thread_count), 0)
        super().__init__(internal)
Ejemplo n.º 2
0
    def __init__(self, gpu_index):
        if gpu_index is None:
            gpu_index = 0

        if isinstance(gpu_index, PythonWrapper.MathEngine):
            super().__init__(gpu_index)
            return

        if gpu_index < 0 or gpu_index >= len(enum_gpu()):
            raise ValueError("GPU with index `gpu_index` doesn't exist.")

        internal = PythonWrapper.MathEngine('gpu', 0, int(gpu_index))
        super().__init__(internal)
Ejemplo n.º 3
0
    def __init__(self, gpu_index=None):
        if gpu_index is None:
            gpu_index = -1

        if isinstance(gpu_index, PythonWrapper.MathEngine):
            super().__init__(gpu_index)
            return

        gpus = enum_gpu()
        if len(gpus) == 0:
            raise ValueError("No GPU available")
        if gpu_index < -1 or gpu_index >= len(gpus):
            raise ValueError("GPU with index `gpu_index` doesn't exist.")

        internal = PythonWrapper.MathEngine('gpu', 0, int(gpu_index))
        super().__init__(internal)