Ejemplo n.º 1
0
import os
import importlib.util

from pykeops.common.gpu_utils import get_gpu_number

###############################################################
# Initialize some variables: the values may be redefined later

##########################################################
# Update config module: Search for GPU

gpu_available = get_gpu_number() > 0

numpy_found = importlib.util.find_spec("numpy") is not None
torch_found = importlib.util.find_spec("torch") is not None

###############################################################
# Compilation options

script_formula_folder = os.path.dirname(os.path.abspath(__file__)) + '/cmake_scripts/script_keops_formula/'
script_template_folder = os.path.dirname(os.path.abspath(__file__)) + '/cmake_scripts/script_template/'
script_linking_folder = os.path.dirname(os.path.abspath(__file__)) + '/cmake_scripts/script_linking/'
script_specific_folder = os.path.dirname(os.path.abspath(__file__)) + '/cmake_scripts/script_specific/'

shared_obj_name = 'KeOps_formula'

bin_folder = ""  # init bin_folder... should be populated with the set_bin_folder() function

# Set the verbosity option: display output of compilations. This is a boolean: False or True
verbose = (
    bool(int(os.environ["PYKEOPS_VERBOSE"]))
Ejemplo n.º 2
0
# Setup
# -------------
# Standard imports:

import matplotlib.pyplot as plt
import numpy as np

from pykeops.numpy import Genred, Vi, Vj
from pykeops.common.gpu_utils import get_gpu_number
import pykeops.config

####################################################################
# Define the list of gpu ids to be tested:

# By default we assume that there are two GPUs available with 0 and 1 labels:
gpuids = [0,1] if get_gpu_number() > 1 else [0]


####################################################################
# KeOps Kernel using Genred
# -------------------------
# Define some arbitrary KeOps routine:

formula   =  'Square(p-a) * Exp(x+y)'
variables = ['x = Vi(3)','y = Vj(3)','a = Vj(1)','p = Pm(1)']

dtype = 'float32'  # May be 'float32' or 'float64'

my_routine = Genred(formula, variables, reduction_op='Sum', axis=1, dtype=dtype)