Here are the examples of the python api nlcpy.request.flush taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
81 Examples
3
Source : module.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def unload_library(ve_lib):
"""Unloads the loaded library.
Parameters
----------
ve_lib : nlcpy.jit.CustomVELibrary
Customized VE library.
Restriction
-----------
Please avoid unloading the shared library linked with FTRACE.
Otherwise, SIGSEGV may occur.
"""
if type(ve_lib) is not CustomVELibrary:
raise TypeError('unrecognized input type: `{}`'.format(type(ve_lib)))
nlcpy.request.flush()
veo._get_veo_proc().unload_library(ve_lib.lib)
3
Source : _warmup.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def _warmup():
xx = []
# allocate VE memory as heap
for i in range(130):
xx.append(nlcpy.zeros(int((1 * 1e8) / 8), dtype='f8'))
nlcpy.request.flush()
xx = []
3
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_scalar_scalar(self, xp, op, in1, in2):
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_array
# out is False
# where is False
# dtype is True
################################
@pytest.mark.full
3
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_scalar_scalar_with_dtype(
self, xp, op, in1, in2, dtype):
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_array
# out is True
# where is False
# dtype is False
################################
@pytest.mark.full
3
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_broadcast_array_array_with_where(
self, xp, op, in1, in2, out, where):
in1 = xp.array(in1)
in2 = xp.array(in2)
out = xp.array(out)
where = xp.array(where)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2, out=out, where=where)
if xp is nlcpy:
nlcpy.request.flush()
return y
3
Source : test_binary_small.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_scalar_scalar(self, xp, op, in1, in2):
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_array
# out is False
# where is False
# dtype is True
################################
@pytest.mark.small
3
Source : test_binary_small.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_scalar_scalar_with_dtype(
self, xp, op, in1, in2, dtype):
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_array
# out is True
# where is False
# dtype is False
################################
@pytest.mark.small
3
Source : test_unary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_unary_cast_array(self, xp, op, in1, order_op):
in1 = xp.array(in1)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, order=order_op)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is scalar
# out is False
# where is False
# dtype is False
################################
@pytest.mark.full
3
Source : test_unary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_unary_cast_scalar(self, xp, op, in1):
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array
# out is False
# where is False
# dtype is True
################################
@pytest.mark.full
3
Source : test_unary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_unary_cast_array_with_dtype(self, xp, op, in1, dtype):
in1 = xp.array(in1)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is scalar
# out is False
# where is False
# dtype is True
################################
@pytest.mark.full
3
Source : test_unary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_unary_cast_scalar_with_dtype(self, xp, op, in1, dtype):
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array
# out is True
# where is False
# dtype is False
################################
@pytest.mark.full
3
Source : test_unary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_unary_cast_scalar_with_out_with_dtype(self, xp, op, in1, out, dtype):
out = xp.array(out)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, out=out, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array
# out is True
# where is True
# dtype is False
################################
@pytest.mark.full
3
Source : test_unary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_unary_cast_scalar_with_out_with_where_with_dtype_broadcast(
self, xp, op, in1, out, where, dtype):
out = xp.array(out)
where = xp.array(where)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(divide='ignore', over='ignore', invalid='ignore'):
with numpy.warnings.catch_warnings():
numpy.warnings.simplefilter('ignore', numpy.ComplexWarning)
func = getattr(xp, op)
y = func(in1, out=out, where=where, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
3
Source : test_unary_small.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_unary_cast_array(self, xp, op, in1):
in1 = xp.array(in1)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is scalar
# out is False
# where is False
# dtype is False
################################
@pytest.mark.small
3
Source : test_unary_small.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_unary_cast_scalar(self, xp, op, in1):
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array
# out is False
# where is False
# dtype is True
################################
@pytest.mark.small
3
Source : test_unary_small.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_unary_cast_array_with_dtype(self, xp, op, in1, dtype):
in1 = xp.array(in1)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is scalar
# out is False
# where is False
# dtype is True
################################
@pytest.mark.small
3
Source : test_unary_small.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_unary_cast_scalar_with_dtype(self, xp, op, in1, dtype):
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array
# out is True
# where is False
# dtype is False
################################
@pytest.mark.small
3
Source : test_unary_small.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_unary_cast_scalar_with_out_with_dtype(self, xp, op, in1, out, dtype):
out = xp.array(out)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, out=out, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array
# out is True
# where is True
# dtype is False
################################
@pytest.mark.small
0
Source : eval.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def use_nlcpy_jit_haversine(lat1, lon1, lat2, lon2, size):
from nlcpy.ve_types import (uint32, uint64, int32, int64,
float32, float64, void_p, void)
vp.request.flush()
start = time.time()
mod = vp.jit.CustomVELibrary(
code=string.Template(
_test_source1_c
).substitute(
dtype=_pytype2ctype(DT)
),
compiler='/opt/nec/ve/bin/ncc',
cflags=vp.jit.get_default_cflags(openmp=True) + \
(('-DFLOAT32',) if DT is np.float32 else ()),
ldflags=vp.jit.get_default_ldflags(openmp=True),
# ftrace=True,
)
if DT is np.float32:
args_type = (float32, float32, uint64, uint64, int64, uint64)
elif DT is np.float64:
args_type = (float64, float64, uint64, uint64, int64, uint64)
else:
raise ValueError
kern = mod.get_function(
'calc_harv',
args_type=args_type,
ret_type=float32
)
end = time.time()
intime["pre"] = end - start
mi = vp.zeros(size, dtype=DT)
vp.request.flush()
start = time.time()
ve_elapsed = kern(lat1, lon1, lat2.ve_adr, lon2.ve_adr, size, mi.ve_adr,
callback=None, sync=True)
end = time.time()
intime["exec(VE+VH)"] = end - start
intime["exec(VE)"] = ve_elapsed
return mi
# Haversine definition
def haversine(lat1, lon1, lat2, lon2, xp):
0
Source : eval.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def gen_data(lat, lon, scale=10, xp=np):
'''
Generates the array replicated X times.
'''
if xp == "nlcpy-jit":
xp = vp
if xp is vp:
vp.request.flush()
start = time.time()
new_lat = xp.arange(scale*len(lat),dtype=DT).reshape(scale, len(lat))
new_lon = xp.arange(scale*len(lon),dtype=DT).reshape(scale, len(lon))
new_lat += lat
new_lon += lon
new_lat = new_lat.ravel()
new_lon = new_lon.ravel()
if xp is vp:
vp.request.flush()
end = time.time()
gen_time = end - start
return new_lat, new_lon, gen_time
def compare(R1, R2):
0
Source : eval.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def run_haversine(scale=10, use_numpy=True, use_nlcpy=False, use_nlcpy_jit=False):
orig_lat = df['latitude'].values
orig_lon = df['longitude'].values
size = orig_lat.size * scale
print(' dtype: ', DT.__name__)
print(' size: ', size)
use_liblist = []
if use_nlcpy_jit:
use_liblist.append("nlcpy-jit")
if use_nlcpy:
use_liblist.append(vp)
if use_numpy:
use_liblist.append(np)
for xp in use_liblist:
if xp is np:
print(" numpy.......", end="", flush=True)
elif xp is vp:
print(" nlcpy.......", end="", flush=True)
else:
print(" nlcpy-jit...", end="", flush=True)
lat, lon, gen_time = gen_data(orig_lat, orig_lon, scale=scale, xp=xp)
gentime[xp] = gen_time
if xp is vp:
vp.request.flush()
start = time.time()
if xp == "nlcpy-jit" :
dist = use_nlcpy_jit_haversine(40.671, -73.985, lat, lon, size)
else:
dist = haversine(40.671, -73.985, lat, lon, xp)
if xp is vp:
vp.request.flush()
end = time.time()
print("done")
print(" generating data:", gen_time)
runtime[xp] = end - start
result[xp] = np.asarray(dist)
print(" caluculation :", runtime[xp])
if xp == "nlcpy-jit":
print(" -> pre : {:.17f}".format(intime["pre"]))
print(" -> exec(VE+VH): {:.17f}".format(intime["exec(VE+VH)"]))
print(" -> exec(VE) : {:.17f}".format(intime["exec(VE)"]))
print(" -> other : {:.17f}".format(runtime["nlcpy-jit"] -
intime["pre"] -
intime["exec(VE+VH)"]))
if use_numpy & use_nlcpy & use_nlcpy_jit:
compare(result[np], result[vp])
compare(result[np], result['nlcpy-jit'])
elif use_numpy & use_nlcpy:
compare(result[np], result[vp])
elif use_numpy & use_nlcpy_jit:
compare(result[np], result['nlcpy-jit'])
elif use_nlcpy & use_nlcpy_jit:
compare(result[vp], result['nlcpy-jit'])
# write result to file
write_to_file(np.array(size, dtype='f8'), SIZE_NAME)
if use_numpy:
write_to_file(np.array(runtime[np], dtype='f8'), T_NP_NAME)
if use_nlcpy:
write_to_file(np.array(runtime[vp], dtype='f8'), T_VP_NAME)
if use_nlcpy_jit:
write_to_file(np.array(runtime["nlcpy-jit"], dtype='f8'), T_J_NAME)
write_to_file(np.array(intime["exec(VE+VH)"], dtype='f8'), T_JE_NAME)
if __name__ == "__main__":
0
Source : prof.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def ftrace_region_begin(message):
"""Begins an ftrace region.
A file ftrace.out is generated after running your program that invokes
this routine.
The ftrace.out includes performance information of your program.
Notes
-----
It is necessary to specify an identical string *message* to
:func:`ftrace_region_begin` and :func:`ftrace_region_end`.
Parameters
----------
message : str
Any string can be specified to distinguish a user-specified region.
See Also
--------
ftrace_region: Enables an ftrace region.
ftrace_region_end : Ends an ftrace region.
Examples
--------
>>> import nlcpy as vp
>>> x = vp.random.rand(10000, 10000)
>>> vp.prof.ftrace_region_begin('dgemm')
>>> # something you want to profile
>>> _ = x @ x
>>> vp.prof.ftrace_region_end('dgemm')
"""
nlcpy.request.flush()
ctx = veo._get_veo_ctx()
lib = _get_lib()
f = lib.find_function("nlcpy_profiling_region_begin".encode('utf-8'))
f.args_type(b"void *")
f.ret_type("void")
if type(message) is not bytes:
message = message.encode('utf-8')
buff = numpy.frombuffer(message, dtype=numpy.uint8)
req = f(ctx, veo.OnStack(buff))
req.wait_result()
def ftrace_region_end(message):
0
Source : prof.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def ftrace_region_end(message):
"""Ends an ftrace region.
A file ftrace.out is generated after running your program that invokes
this routine.
The ftrace.out includes performance information of your program.
Notes
-----
It is necessary to specify an identical string *message* to
:func:`ftrace_region_begin` and :func:`ftrace_region_end`.
Parameters
----------
message : str
Any string can be specified to distinguish a user-specified region.
See Also
--------
ftrace_region : Enables an ftrace region.
ftrace_region_begin : Begins an ftrace region.
Examples
--------
>>> import nlcpy as vp
>>> x = vp.random.rand(10000, 10000)
>>> vp.prof.ftrace_region_begin('dgemm')
>>> # something you want to profile
>>> _ = x @ x
>>> vp.prof.ftrace_region_end('dgemm')
"""
nlcpy.request.flush()
ctx = veo._get_veo_ctx()
lib = _get_lib()
f = lib.find_function("nlcpy_profiling_region_end".encode('utf-8'))
f.args_type(b"void *")
f.ret_type("void")
if type(message) is not bytes:
message = message.encode('utf-8')
buff = numpy.frombuffer(message, dtype=numpy.uint8)
req = f(ctx, veo.OnStack(buff))
req.wait_result()
@contextlib.contextmanager
0
Source : helper.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def numpy_nlcpy_raises(name='xp', sp_name=None, scipy_name=None,
accept_error=Exception, ignore_msg=False):
"""Decorator that checks the NumPy and nlcpy throw same errors.
Args:
name(str): Argument name whose value is either
``numpy`` or ``nlcpy`` module.
sp_name(str or None): Argument name whose value is either
``scipy.sparse`` or ``nlcpyx.scipy.sparse`` module. If ``None``, no
argument is given for the modules.
scipy_name(str or None): Argument name whose value is either ``scipy``
or ``nlcpyx.scipy`` module. If ``None``, no argument is given for
the modules.
accept_error(bool, Exception or tuple of Exception): Specify
acceptable errors. When both NumPy test and nlcpy test raises the
same type of errors, and the type of the errors is specified with
this argument, the errors are ignored and not raised.
If it is ``True`` all error types are acceptable.
If it is ``False`` no error is acceptable.
ignore_msg(bool): if True, raised error message check is skipped.
Decorated test fixture is required throw same errors
even if ``xp`` is ``numpy`` or ``nlcpy``.
"""
def decorator(impl):
@functools.wraps(impl)
def test_func(self, *args, **kw):
# if sp_name:
# kw[sp_name] = nlcpyx.scipy.sparse
# if scipy_name:
# kw[scipy_name] = nlcpyx.scipy
kw[name] = nlcpy
nlcpy_msg = None
numpy_msg = None
try:
impl(self, *args, **kw)
nlcpy.request.flush()
nlcpy_error = None
nlcpy_tb = None
except Exception as e:
nlcpy_error = e
nlcpy_msg = str(e)
nlcpy_tb = traceback.format_exc()
if sp_name:
import scipy.sparse
kw[sp_name] = scipy.sparse
if scipy_name:
import scipy
kw[scipy_name] = scipy
kw[name] = numpy
try:
impl(self, *args, **kw)
numpy_error = None
numpy_tb = None
except Exception as e:
numpy_error = e
numpy_msg = str(e)
numpy_tb = traceback.format_exc()
if ignore_msg:
nlcpy_msg = None
numpy_msg = None
_check_nlcpy_numpy_error(self, nlcpy_error, nlcpy_msg,
nlcpy_tb, numpy_error, numpy_msg,
numpy_tb, accept_error=accept_error)
return test_func
return decorator
def for_dtypes(dtypes, name='dtype'):
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_array(self, xp, op, in1, in2, order_op):
in1 = xp.array(in1)
in2 = xp.array(in2)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2, order=order_op)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_scalar
# out is False
# where is False
# dtype is False
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_scalar(self, xp, op, in1, in2):
in1 = xp.array(in1)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is scalar_scalar
# out is False
# where is False
# dtype is False
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_array_with_dtype(self, xp, op, in1, in2, dtype):
in1 = xp.array(in1)
in2 = xp.array(in2)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_scalar
# out is False
# where is False
# dtype is True
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_scalar_with_dtype(
self, xp, op, in1, in2, dtype):
in1 = xp.array(in1)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is scalar_scalar
# out is False
# where is False
# dtype is True
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_array_with_out(self, xp, op, in1, in2, out):
in1 = xp.array(in1)
in2 = xp.array(in2)
out = xp.array(out)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2, out=out)
if xp is numpy and op in float16_op_set:
if in1.dtype == numpy.dtype('bool') and \
in2.dtype == numpy.dtype('bool'):
y = func(in1, in2, out=out, dtype='f4')
return y
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_scalar
# out is True
# where is False
# dtype is False
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_scalar_with_out(self, xp, op, in1, in2, out):
in1 = xp.array(in1)
out = xp.array(out)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2, out=out)
if xp is numpy and op in float16_op_set:
if in1.dtype == numpy.dtype('bool') and \
isinstance(in2, bool):
y = func(in1, in2, out=out, dtype='f4')
return y
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is scalar_scalar
# out is True
# where is False
# dtype is False
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_scalar_scalar_with_out(self, xp, op, in1, in2, out):
out = xp.array(out)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2, out=out)
if xp is numpy and op in float16_op_set:
if isinstance(in1, bool) and \
isinstance(in2, bool):
y = func(in1, in2, out=out, dtype='f4')
return y
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_array
# out is True(for broadcast)
# where is False
# dtype is False
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_array_with_out_broadcast(
self, xp, op, in1, in2, out):
in1 = xp.array(in1)
in2 = xp.array(in2)
out = xp.array(out)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2, out=out)
if xp is numpy and op in float16_op_set:
if in1.dtype == numpy.dtype('bool') and \
in2.dtype == numpy.dtype('bool'):
y = func(in1, in2, out=out, dtype='f4')
return y
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_array
# out is True
# where is False
# dtype is True
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_array_with_out_with_dtype(
self, xp, op, in1, in2, out, dtype):
in1 = xp.array(in1)
in2 = xp.array(in2)
out = xp.array(out)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2, out=out, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_scalar
# out is True
# where is False
# dtype is True
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_scalar_with_out_with_dtype(
self, xp, op, in1, in2, out, dtype):
in1 = xp.array(in1)
out = xp.array(out)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2, out=out, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is scalar_scalar
# out is True
# where is False
# dtype is True
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_scalar_scalar_with_out_with_dtype(
self, xp, op, in1, in2, out, dtype):
out = xp.array(out)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2, out=out, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_array
# out is True
# where is True
# dtype is False
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_array_with_out_with_where(
self, xp, op, in1, in2, out, where):
in1 = xp.array(in1)
in2 = xp.array(in2)
out = xp.array(out)
where = xp.array(where)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
with numpy.warnings.catch_warnings():
numpy.warnings.simplefilter(
'ignore', numpy.ComplexWarning)
func = getattr(xp, op)
y = func(in1, in2, out=out, where=where)
if xp is numpy and op in float16_op_set:
if in1.dtype == numpy.dtype('bool') and \
in2.dtype == numpy.dtype('bool'):
y = func(in1, in2, out=out, where=where, dtype='f4')
return y
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_scalar
# out is True
# where is True
# dtype is False
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_scalar_with_out_with_where(
self, xp, op, in1, in2, out, where):
in1 = xp.array(in1)
out = xp.array(out)
where = xp.array(where)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
with numpy.warnings.catch_warnings():
numpy.warnings.simplefilter(
'ignore', numpy.ComplexWarning)
func = getattr(xp, op)
y = func(in1, in2, out=out, where=where)
if xp is numpy and op in float16_op_set:
if in1.dtype == numpy.dtype('bool') and \
isinstance(in2, bool):
y = func(in1, in2, out=out, where=where, dtype='f4')
return y
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is scalar_scalar
# out is True
# where is True
# dtype is False
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_scalar_scalar_with_out_with_where(
self, xp, op, in1, in2, out, where):
out = xp.array(out)
where = xp.array(where)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
with numpy.warnings.catch_warnings():
numpy.warnings.simplefilter(
'ignore', numpy.ComplexWarning)
func = getattr(xp, op)
y = func(in1, in2, out=out, where=where)
if xp is numpy and op in float16_op_set:
if isinstance(in1, bool) and \
isinstance(in2, bool):
y = func(in1, in2, out=out, where=where, dtype='f4')
return y
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_array
# out is True(for broadcast)
# where is True(for broadcast)
# dtype is False
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_array_with_out_with_where_broadcast(
self, xp, op, in1, in2, out, where):
in1 = xp.array(in1)
in2 = xp.array(in2)
out = xp.array(out)
where = xp.array(where)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
with numpy.warnings.catch_warnings():
numpy.warnings.simplefilter(
'ignore', numpy.ComplexWarning)
func = getattr(xp, op)
y = func(in1, in2, out=out, where=where)
if xp is numpy and op in float16_op_set:
if in1.dtype == numpy.dtype('bool') and \
in2.dtype == numpy.dtype('bool'):
y = func(in1, in2, out=out, where=where, dtype='f4')
return y
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_array
# out is True
# where is True
# dtype is True
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_array_with_out_with_where_with_dtype(
self, xp, op, in1, in2, out, where, dtype):
in1 = xp.array(in1)
in2 = xp.array(in2)
out = xp.array(out)
where = xp.array(where)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
with numpy.warnings.catch_warnings():
numpy.warnings.simplefilter(
'ignore', numpy.ComplexWarning)
func = getattr(xp, op)
y = func(in1, in2, out=out, where=where, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_scalar
# out is True
# where is True
# dtype is True
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_scalar_with_out_with_where_with_dtype(
self, xp, op, in1, in2, out, where, dtype):
in1 = xp.array(in1)
out = xp.array(out)
where = xp.array(where)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
with numpy.warnings.catch_warnings():
numpy.warnings.simplefilter(
'ignore', numpy.ComplexWarning)
func = getattr(xp, op)
y = func(in1, in2, out=out, where=where, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is scalar_scalar
# out is True
# where is True
# dtype is True
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_scalar_scalar_with_out_with_where_with_dtype(
self, xp, op, in1, in2, out, where, dtype):
out = xp.array(out)
where = xp.array(where)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
with numpy.warnings.catch_warnings():
numpy.warnings.simplefilter(
'ignore', numpy.ComplexWarning)
func = getattr(xp, op)
y = func(in1, in2, out=out, where=where, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
###########################################################
#
# testing for broadcast
#
###########################################################
shapes_base = [(4, ),
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_broadcast_array_array(self, xp, op, in1, in2):
in1 = xp.array(in1)
in2 = xp.array(in2)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is scalar_array
# out is False
# where is False
# dtype is False
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_broadcast_array_scalar(self, xp, op, in1, in2):
in1 = xp.array(in1)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_array
# out is True
# where is False
# dtype is False
################################
@pytest.mark.full
0
Source : test_binary_full.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_broadcast_array_array_with_out(
self, xp, op, in1, in2, out):
in1 = xp.array(in1)
in2 = xp.array(in2)
out = xp.array(out)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2, out=out)
if xp is numpy and op in float16_op_set:
if in1.dtype == numpy.dtype('bool') and \
in2.dtype == numpy.dtype('bool'):
y = func(in1, in2, out=out, dtype='f4')
return y
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_array
# out is True
# where is True
# dtype is False
################################
@pytest.mark.full
0
Source : test_binary_small.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_array(self, xp, op, in1, in2):
in1 = xp.array(in1)
in2 = xp.array(in2)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_scalar
# out is False
# where is False
# dtype is False
################################
@pytest.mark.small
0
Source : test_binary_small.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_scalar(self, xp, op, in1, in2):
in1 = xp.array(in1)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is scalar_scalar
# out is False
# where is False
# dtype is False
################################
@pytest.mark.small
0
Source : test_binary_small.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_array_with_dtype(self, xp, op, in1, in2, dtype):
in1 = xp.array(in1)
in2 = xp.array(in2)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_scalar
# out is False
# where is False
# dtype is True
################################
@pytest.mark.small
0
Source : test_binary_small.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_scalar_with_dtype(
self, xp, op, in1, in2, dtype):
in1 = xp.array(in1)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2, dtype=dtype)
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is scalar_scalar
# out is False
# where is False
# dtype is True
################################
@pytest.mark.small
0
Source : test_binary_small.py
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
with BSD 3-Clause "New" or "Revised" License
from SX-Aurora
def test_binary_cast_array_array_with_out(self, xp, op, in1, in2, out):
in1 = xp.array(in1)
in2 = xp.array(in2)
out = xp.array(out)
with testing.NumpyError(divide='ignore'):
with testing.NlcpyError(
divide='ignore', over='ignore', invalid='ignore'):
func = getattr(xp, op)
y = func(in1, in2, out=out)
if xp is numpy and op in float16_op_set:
if in1.dtype.kind == 'b' and in2.dtype.kind == 'b':
y = func(in1, in2, out=out, dtype='f4')
return y
if xp is nlcpy:
nlcpy.request.flush()
return y
################################
# *** testing parameter ***
# input is array_scalar
# out is True
# where is False
# dtype is False
################################
@pytest.mark.small
See More Examples