Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a0aa3fe

Browse files
committed
removes defaults, adds missing 3.7 imports
1 parent b8b0672 commit a0aa3fe

File tree

13 files changed

+149
-684
lines changed

13 files changed

+149
-684
lines changed

‎arrayfire/__init__.py

Lines changed: 79 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -49,58 +49,60 @@
4949
"""
5050

5151
from .algorithm import (
52-
accum, all_true, any_true, diff1, diff2, imax, imin, max, min, product, scan, scan_by_key, set_intersect,
53-
set_union, set_unique, sort, sort_by_key, sort_index, where)
52+
accum, all_true, allTrueByKey, any_true, anyTrueByKey, count, countByKey, diff1, diff2, imax, imin, max, maxByKey, min, minByKey, product, productByKey, scan, scan_by_key, set_intersect,
53+
set_union, set_unique, sort, sort_by_key, sort_index, sum, sumByKey, where)
5454
from .arith import (
55-
abs, acos, acosh, arg, asin, asinh, atan, atan2, atanh, cbrt, ceil, clamp, conjg, cos, cosh, cplx, erf, erfc, exp,
56-
expm1, factorial, floor, hypot, imag, isinf, isnan, iszero, lgamma, log, log1p, log2, log10, maxof, minof, pow,
57-
pow2, real, rem, root, round, sigmoid, sign, sin, sinh, sqrt, tan, tanh, tgamma, trunc)
55+
abs, acos, acosh, arg, asin, asinh, atan, atan2, atanh, cast, cbrt, ceil, clamp, conjg, cos, cosh, cplx, erf, erfc, exp,
56+
expm1, factorial, floor, hypot, imag, isinf, isnan, iszero, lgamma, log, log1p, log2, log10, maxof, minof,
57+
mod, pow,
58+
pow2, real, rem, root, round, rsqrt, sigmoid, sign, sin, sinh, sqrt, tan, tanh, tgamma, trunc)
5859
from .array import (
59-
Array, cast, constant_array, count, display, get_display_dims_limit, read_array, save_array,
60-
set_display_dims_limit, sum, transpose, transpose_inplace)
60+
Array, constant_array, display, get_display_dims_limit, read_array, save_array,
61+
set_display_dims_limit, transpose, transpose_inplace)
6162
from .base import BaseArray
6263
from .bcast import broadcast
63-
from .blas import dot, matmul, matmulNT, matmulTN, matmulTT
64+
from .blas import dot, matmul, matmulNT, matmulTN, matmulTT, gemm
6465
from .cuda import get_native_id, get_stream, set_native_id
6566
from .data import (
66-
constant, diag, flat, flip, identity, iota, join, lookup, lower, moddims, range, reorder, replace, select, shift,
67+
constant, diag, flat, flip, identity, iota, join, lookup, lower, moddims, pad, range, reorder, replace, select, shift,
6768
tile, upper)
6869
from .library import (
69-
BACKEND, BINARYOP, CANNY_THRESHOLD, COLORMAP, CONNECTIVITY, CONV_DOMAIN, CONV_MODE, CSPACE, DIFFUSION, ERR, FLUX,
70-
HOMOGRAPHY, IMAGE_FORMAT, INTERP, MARKER, MATCH, MATPROP, MOMENT, NORM, PAD, STORAGE, TOPK, YCC_STD, Dtype, Source)
70+
BACKEND, BINARYOP, CANNY_THRESHOLD, COLORMAP, CONNECTIVITY, CONV_DOMAIN, CONV_GRADIENT, CONV_MODE, CSPACE, DIFFUSION, ERR, FLUX,
71+
HOMOGRAPHY, IMAGE_FORMAT, INTERP, ITERATIVE_DECONV, INVERSE_DECONV, MARKER, MATCH, MATPROP, MOMENT, NORM, PAD, RANDOM_ENGINE, STORAGE, TOPK, VARIANCE, YCC_STD, Dtype, Source, AF_VER_MAJOR, FORGE_VER_MAJOR)
7172
from .device import (
7273
alloc_device, alloc_host, alloc_pinned, device_gc, device_info, device_mem_info, eval, free_device, free_host,
73-
free_pinned, get_device, get_device_count, get_device_ptr, get_manual_eval_flag, get_reversion, get_version, info,
74-
info_str, init, is_dbl_supported, is_locked_array, lock_array, lock_device_ptr, print_mem_info, set_device,
74+
free_pinned, get_device, get_device_count, get_device_ptr, get_manual_eval_flag, info,
75+
info_str, init, is_dbl_supported, is_half_supported, is_locked_array, lock_array, lock_device_ptr, print_mem_info, set_device,
7576
set_manual_eval_flag, sync, unlock_array, unlock_device_ptr)
7677
from .graphics import Window
7778
from .image import (
78-
anisotropic_diffusion, bilateral, canny, color_space, dilate, dilate3, erode, erode3, gaussian_kernel, gradient,
79-
gray2rgb, hist_equal, histogram, hsv2rgb, is_image_io_available, load_image, load_image_native, maxfilt,
79+
anisotropic_diffusion, bilateral, canny, color_space, confidenceCC, dilate, dilate3, erode, erode3, gaussian_kernel, gradient,
80+
gray2rgb, hist_equal, histogram, hsv2rgb, is_image_io_available, iterativeDeconv, inverseDeconv, load_image, load_image_native, maxfilt,
8081
mean_shift, minfilt, moments, regions, resize, rgb2gray, rgb2hsv, rgb2ycbcr, rotate, sat, save_image,
8182
save_image_native, scale, skew, sobel_derivatives, sobel_filter, transform, translate, unwrap, wrap, ycbcr2rgb)
8283
from .index import Index, ParallelRange, Seq
83-
from .interop import AF_NUMBA_FOUND, AF_NUMPY_FOUND, AF_PYCUDA_FOUND, AF_PYOPENCL_FOUND
84+
from .interop import AF_NUMBA_FOUND, AF_NUMPY_FOUND, AF_PYCUDA_FOUND, AF_PYOPENCL_FOUND, to_array
8485
from .lapack import (
85-
cholesky, cholesky_inplace, det, inverse, is_lapack_available, lu, lu_inplace, norm, qr, qr_inplace, rank, solve,
86+
cholesky, cholesky_inplace, det, inverse, is_lapack_available, lu, lu_inplace, norm, pinverse, qr, qr_inplace, rank, solve,
8687
solve_lu, svd, svd_inplace)
8788
from .library import (
8889
get_active_backend, get_available_backends, get_backend, get_backend_count, get_backend_id, get_device_id,
8990
get_size_of, safe_call, set_backend)
91+
from .ml import convolve2GradientNN
9092
from .random import (
91-
RANDOM_ENGINE, Random_Engine, get_default_random_engine, get_seed, randn, randu, set_default_random_engine_type,
93+
Random_Engine, get_default_random_engine, get_seed, randn, randu, set_default_random_engine_type,
9294
set_seed)
9395
from .signal import (
94-
approx1, approx2, convolve, convolve1, convolve2, convolve2_separable, convolve3, dft, fft, fft2, fft2_c2r,
96+
approx1, approx1_uniform, approx2, approx2_uniform, convolve, convolve1, convolve2, convolve2NN, convolve2_separable, convolve3, dft, fft, fft2, fft2_c2r,
9597
fft2_inplace, fft2_r2c, fft3, fft3_c2r, fft3_inplace, fft3_r2c, fft_c2r, fft_convolve, fft_convolve1,
9698
fft_convolve2, fft_convolve3, fft_inplace, fft_r2c, fir, idft, ifft, ifft2, ifft2_inplace, ifft3, ifft3_inplace,
9799
ifft_inplace, iir, medfilt, medfilt1, medfilt2, set_fft_plan_cache_size)
98100
from .sparse import (
99101
convert_sparse, convert_sparse_to_dense, create_sparse, create_sparse_from_dense, create_sparse_from_host,
100102
sparse_get_col_idx, sparse_get_info, sparse_get_nnz, sparse_get_row_idx, sparse_get_storage, sparse_get_values)
101-
from .statistics import corrcoef, cov, mean, median, stdev, topk, var
103+
from .statistics import corrcoef, cov, mean, meanvar, median, stdev, topk, var
102104
from .timer import timeit
103-
from .util import dim4, dim4_to_tuple, implicit_dtype, number_dtype, to_str
105+
from .util import dim4, dim4_to_tuple, implicit_dtype, number_dtype, to_str, get_reversion, get_version, to_dtype, to_typecode, to_c_type
104106

105107
try:
106108
# FIXME: pycuda imported but unused
@@ -109,83 +111,87 @@
109111
pass
110112

111113

112-
# do not export default modules as part of arrayfire
113-
del ct
114-
del inspect
115-
del numbers
116-
del os
117-
118-
if (AF_NUMPY_FOUND):
119-
del np
120-
121114
__all__ = [
122115
# algorithm
123-
"accum", "all_true", "any_true", "max", "min", "product", "scan", "scan_by_key", "set_intersect", "set_union",
124-
"set_unique", "sort", "sort_by_key", "sort_index", "imin", "imax", "where", "diff1", "diff2",
116+
"accum", "all_true", "allTrueByKey", "any_true", "anyTrueByKey", "count", "countByKey",
117+
"diff1", "diff2", "imax", "imin", "max", "maxByKey", "min", "minByKey", "product",
118+
"productByKey", "scan", "scan_by_key", "set_intersect", "set_union", "set_unique",
119+
"sort", "sort_by_key", "sort_index", "sum", "sumByKey", "where",
125120
# arith
126-
"abs", "acos", "acosh", "arg", "asin", "asinh", "atan", "atan2", "atanh", "cbrt", "ceil", "clamp", "conjg", "cos",
127-
"cosh", "cplx", "erf", "erfc", "exp", "expm1", "factorial", "floor", "hypot", "imag", "isinf", "isnan", "iszero",
128-
"lgamma", "log", "log1p", "log2", "log10", "maxof", "minof", "pow", "pow2", "real", "rem", "root", "round",
121+
"abs", "acos", "acosh", "arg", "asin", "asinh", "atan", "atan2", "atanh",
122+
"cast", "cbrt", "ceil", "clamp", "conjg", "cos", "cosh", "cplx", "erf",
123+
"erfc", "exp", "expm1", "factorial", "floor", "hypot", "imag", "isinf",
124+
"isnan", "iszero", "lgamma", "log", "log1p", "log2", "log10", "maxof",
125+
"minof", "mod", "pow", "pow2", "real", "rem", "root", "round", "rsqrt",
129126
"sigmoid", "sign", "sin", "sinh", "sqrt", "tan", "tanh", "tgamma", "trunc",
130127
# array
131-
"Array", "cast", "count", "sum", "transpose", "transpose_inplace", "display", "set_display_dims_limit",
132-
"get_display_dims_limit", "constant_array", "save_array", "read_array",
128+
"Array", "constant_array", "display", "get_display_dims_limit", "read_array",
129+
"save_array", "set_display_dims_limit", "transpose", "transpose_inplace",
133130
# base
134131
"BaseArray",
135132
# bcast
136133
"broadcast",
137134
# blas
138-
"dot", "matmul", "matmulTN", "matmulNT", "matmulTT",
139-
#cuda
135+
"dot", "matmul", "matmulNT", "matmulTN", "matmulTT", "gemm",
136+
#cuda
140137
"get_native_id", "get_stream", "set_native_id",
141138
# data
142-
"constant", "diag", "flat", "flip", "identity", "iota", "join", "lower", "moddims", "range", "reorder", "replace",
143-
"select", "shift", "tile", "upper", "lookup",
144-
# library enums
145-
"BINARYOP", "CSPACE", "DIFFUSION", "FLUX", "MATPROP", "NORM", "Dtype", "COLORMAP", "ERR", "Source", "INTERP",
146-
"PAD", "CONNECTIVITY", "CONV_MODE", "CONV_DOMAIN", "MATCH", "YCC_STD", "IMAGE_FORMAT", "HOMOGRAPHY", "BACKEND",
147-
"MARKER", "MOMENT", "STORAGE", "CANNY_THRESHOLD", "FLUX", "TOPK",
139+
"constant", "diag", "flat", "flip", "identity", "iota", "join", "lookup",
140+
"lower", "moddims", "pad", "range", "reorder", "replace", "select",
141+
"shift", "tile", "upper",
142+
# library
143+
"BACKEND", "BINARYOP", "CANNY_THRESHOLD", "COLORMAP", "CONNECTIVITY", "CONV_DOMAIN",
144+
"CONV_GRADIENT", "CONV_MODE", "CSPACE", "DIFFUSION", "ERR", "FLUX", "HOMOGRAPHY",
145+
"IMAGE_FORMAT", "INTERP", "ITERATIVE_DECONV", "INVERSE_DECONV", "MARKER", "MATCH",
146+
"MATPROP", "MOMENT", "NORM", "PAD", "RANDOM_ENGINE", "STORAGE", "TOPK", "VARIANCE",
147+
"YCC_STD", "Dtype", "Source", "AF_VER_MAJOR", "FORGE_VER_MAJOR",
148148
# device
149-
"device_gc", "device_info", "device_mem_info", "eval", "get_device", "get_device_count", "get_device_ptr",
150-
"get_manual_eval_flag", "info", "is_dbl_supported", "is_locked_array", "lock_array", "set_device",
151-
"set_manual_eval_flag", "sync", "unlock_array", "get_reversion", "get_version", "init", "info_str",
152-
"print_mem_info", "lock_device_ptr", "unlock_device_ptr", "alloc_device", "alloc_host", "alloc_pinned",
153-
"free_device", "free_host", "free_pinned",
149+
"alloc_device", "alloc_host", "alloc_pinned", "device_gc", "device_info", "device_mem_info",
150+
"eval", "free_device", "free_host", "free_pinned", "get_device", "get_device_count",
151+
"get_device_ptr", "get_manual_eval_flag", "info", "info_str", "init", "is_dbl_supported",
152+
"is_half_supported", "is_locked_array", "lock_array", "lock_device_ptr", "print_mem_info",
153+
"set_device", "set_manual_eval_flag", "sync", "unlock_array", "unlock_device_ptr",
154154
# graphics
155155
"Window",
156156
# image
157-
"anisotropic_diffusion", "bilateral", "canny", "color_space", "dilate", "dilate3", "erode", "erode3",
158-
"gaussian_kernel", "gradient", "gray2rgb", "hist_equal", "histogram", "hsv2rgb", "maxfilt", "mean_shift",
159-
"minfilt", "regions", "resize", "rgb2gray", "rgb2hsv", "rgb2ycbcr", "rotate", "sat", "scale", "skew",
160-
"sobel_derivatives", "sobel_filter", "transform", "translate", "unwrap", "wrap", "ycbcr2rgb", "load_image",
161-
"save_image", "load_image_native", "save_image_native", "moments", "is_image_io_available",
157+
"anisotropic_diffusion", "bilateral", "canny", "color_space", "confidenceCC", "dilate", "dilate3",
158+
"erode", "erode3", "gaussian_kernel", "gradient", "gray2rgb", "hist_equal", "histogram", "hsv2rgb",
159+
"is_image_io_available", "iterativeDeconv", "inverseDeconv", "load_image", "load_image_native",
160+
"maxfilt", "mean_shift", "minfilt", "moments", "regions", "resize", "rgb2gray", "rgb2hsv", "rgb2ycbcr",
161+
"rotate", "sat", "save_image", "save_image_native", "scale", "skew", "sobel_derivatives", "sobel_filter",
162+
"transform", "translate", "unwrap", "wrap", "ycbcr2rgb",
162163
# index
163-
"ParallelRange", "Seq", "Index",
164+
"Index", "ParallelRange", "Seq",
164165
# interop
165-
"AF_NUMBA_FOUND", "AF_NUMPY_FOUND", "AF_PYCUDA_FOUND", "AF_PYOPENCL_FOUND",
166+
"AF_NUMBA_FOUND", "AF_NUMPY_FOUND", "AF_PYCUDA_FOUND", "AF_PYOPENCL_FOUND","to_array",
166167
# lapack
167-
"cholesky", "cholesky_inplace", "det", "inverse", "lu", "lu_inplace", "norm", "qr", "qr_inplace", "rank", "solve",
168-
"solve_lu", "svd", "svd_inplace", "is_lapack_available",
168+
"cholesky", "cholesky_inplace", "det", "inverse", "is_lapack_available", "lu", "lu_inplace",
169+
"norm", "pinverse", "qr", "qr_inplace", "rank", "solve", "solve_lu", "svd", "svd_inplace",
169170
# library
170-
"get_active_backend", "set_backend", "get_backend", "get_backend_id", "get_backend_count", "safe_call",
171-
"get_available_backends", "get_device_id", "get_size_of",
171+
"get_active_backend", "get_available_backends", "get_backend", "get_backend_count",
172+
"get_backend_id", "get_device_id", "get_size_of", "safe_call", "set_backend",
173+
# ml
174+
"convolve2GradientNN",
172175
# random
173-
"RANDOM_ENGINE", "Random_Engine", "get_seed", "randn", "randu", "set_seed", "set_default_random_engine_type",
174-
"get_default_random_engine",
176+
"Random_Engine", "get_default_random_engine", "get_seed", "randn", "randu",
177+
"set_default_random_engine_type", "set_seed",
175178
# signal
176-
"approx1", "approx2", "convolve", "convolve1", "convolve2", "convolve3", "dft", "fft", "fft2", "fft2_c2r",
177-
"fft2_inplace", "fft2_r2c", "fft3", "fft3_c2r", "fft3_inplace", "fft3_r2c", "fft_c2r", "fft_convolve",
178-
"fft_convolve1", "fft_convolve2", "fft_convolve3", "fft_inplace", "fft_r2c", "fir", "idft", "ifft", "ifft2",
179-
"ifft2_inplace", "ifft3", "ifft3_inplace", "ifft_inplace", "iir", "medfilt", "medfilt1", "medfilt2",
180-
"convolve2_separable", "set_fft_plan_cache_size",
179+
"approx1", "approx1_uniform", "approx2", "approx2_uniform", "convolve", "convolve1",
180+
"convolve2", "convolve2NN", "convolve2_separable", "convolve3", "dft", "fft",
181+
"fft2", "fft2_c2r", "fft2_inplace", "fft2_r2c", "fft3", "fft3_c2r", "fft3_inplace",
182+
"fft3_r2c", "fft_c2r", "fft_convolve", "fft_convolve1", "fft_convolve2", "fft_convolve3",
183+
"fft_inplace", "fft_r2c", "fir", "idft", "ifft", "ifft2", "ifft2_inplace", "ifft3",
184+
"ifft3_inplace", "ifft_inplace", "iir", "medfilt", "medfilt1", "medfilt2",
185+
"set_fft_plan_cache_size",
181186
# sparse
182-
"create_sparse_from_dense", "sparse_get_col_idx", "sparse_get_info", "sparse_get_nnz", "sparse_get_row_idx",
183-
"sparse_get_storage", "sparse_get_values", "create_sparse", "create_sparse_from_host", "convert_sparse_to_dense",
184-
"convert_sparse",
187+
"convert_sparse", "convert_sparse_to_dense", "create_sparse", "create_sparse_from_dense",
188+
"create_sparse_from_host", "sparse_get_col_idx", "sparse_get_info", "sparse_get_nnz",
189+
"sparse_get_row_idx", "sparse_get_storage", "sparse_get_values",
185190
# statistics
186-
"corrcoef", "mean", "median", "stdev", "topk", "var", "cov",
191+
"corrcoef", "cov", "mean", "meanvar", "median", "stdev", "topk", "var",
187192
# timer
188193
"timeit",
189194
# util
190-
"to_str", "dim4", "number_dtype", "implicit_dtype", "dim4_to_tuple"
195+
"dim4", "dim4_to_tuple", "implicit_dtype", "number_dtype", "to_str", "get_reversion",
196+
"get_version", "to_dtype", "to_typecode", "to_c_type"
191197
]

‎arrayfire/algorithm.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Vector algorithms (sum, min, sort, etc).
1212
"""
1313

14-
from .array import Array, _nan_parallel_dim, _nan_reduce_all, _parallel_dim, _reduce_all
14+
from .array import Array
1515
from .library import backend, safe_call, BINARYOP, c_bool_t, c_double_t, c_int_t, c_pointer, c_uint_t
1616

1717
def _parallel_dim(a, dim, c_func):
@@ -82,6 +82,22 @@ def sum(a, dim=None, nan_val=None):
8282
nan_val: optional: scalar. default: None
8383
The value that replaces NaN in the array
8484
85+
Returns
86+
-------
87+
out: af.Array or scalar number
88+
The sum of all elements in `a` along dimension `dim`.
89+
If `dim` is `None`, sum of the entire Array is returned.
90+
"""
91+
if nan_val is not None:
92+
if dim is not None:
93+
return _nan_parallel_dim(a, dim, backend.get().af_sum_nan, nan_val)
94+
return _nan_reduce_all(a, backend.get().af_sum_nan_all, nan_val)
95+
96+
if dim is not None:
97+
return _parallel_dim(a, dim, backend.get().af_sum)
98+
return _reduce_all(a, backend.get().af_sum_all)
99+
100+
85101

86102

87103
def sumByKey(keys, vals, dim=-1, nan_val=None):
@@ -353,7 +369,17 @@ def count(a, dim=None):
353369
Multi dimensional arrayfire array.
354370
dim: optional: int. default: None
355371
Dimension along which the the non zero elements are to be counted.
356-
return _reduce_all(a, backend.get().af_any_true_all)
372+
373+
Returns
374+
-------
375+
out: af.Array or scalar number
376+
The count of non zero elements in `a` along `dim`.
377+
If `dim` is `None`, the total number of non zero elements in `a`.
378+
"""
379+
if dim is not None:
380+
return _parallel_dim(a, dim, backend.get().af_count)
381+
else:
382+
return _reduce_all(a, backend.get().af_count_all)
357383

358384

359385
def countByKey(keys, vals, dim=-1):

‎arrayfire/arith.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,35 @@ def _arith_unary_func(a, c_func):
5353
return out
5454

5555

56+
def cast(a, dtype):
57+
"""
58+
Cast an array to a specified type
59+
Parameters
60+
----------
61+
a : af.Array
62+
Multi dimensional arrayfire array.
63+
dtype: af.Dtype
64+
Must be one of the following:
65+
- Dtype.f32 for float
66+
- Dtype.f64 for double
67+
- Dtype.b8 for bool
68+
- Dtype.u8 for unsigned char
69+
- Dtype.s32 for signed 32 bit integer
70+
- Dtype.u32 for unsigned 32 bit integer
71+
- Dtype.s64 for signed 64 bit integer
72+
- Dtype.u64 for unsigned 64 bit integer
73+
- Dtype.c32 for 32 bit complex number
74+
- Dtype.c64 for 64 bit complex number
75+
Returns
76+
--------
77+
out : af.Array
78+
array containing the values from `a` after converting to `dtype`.
79+
"""
80+
out=Array()
81+
safe_call(backend.get().af_cast(c_pointer(out.arr), a.arr, dtype.value))
82+
return out
83+
84+
5685
def minof(lhs, rhs):
5786
"""
5887
Find the minimum value of two inputs at each location.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /