__init__.py 16.2 KB
Newer Older
1
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved
2 3 4 5 6 7 8 9 10 11 12 13
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
14

15 16
from .attribute import is_complex  # noqa: F401
from .attribute import is_integer  # noqa: F401
17 18 19 20
from .attribute import rank  # noqa: F401
from .attribute import shape  # noqa: F401
from .attribute import real  # noqa: F401
from .attribute import imag  # noqa: F401
W
wuhuanzhou 已提交
21
from .attribute import is_floating_point  # noqa: F401
22 23
from .creation import to_tensor  # noqa: F401
from .creation import diag  # noqa: F401
L
Li Min 已提交
24
from .creation import diagflat  # noqa: F401
25 26 27 28 29 30 31 32 33 34 35 36 37 38
from .creation import eye  # noqa: F401
from .creation import linspace  # noqa: F401
from .creation import ones  # noqa: F401
from .creation import ones_like  # noqa: F401
from .creation import zeros  # noqa: F401
from .creation import zeros_like  # noqa: F401
from .creation import arange  # noqa: F401
from .creation import full  # noqa: F401
from .creation import full_like  # noqa: F401
from .creation import triu  # noqa: F401
from .creation import tril  # noqa: F401
from .creation import meshgrid  # noqa: F401
from .creation import empty  # noqa: F401
from .creation import empty_like  # noqa: F401
F
Feiyu Chan 已提交
39
from .creation import complex  # noqa: F401
40 41
from .linalg import matmul  # noqa: F401
from .linalg import dot  # noqa: F401
Z
zhiboniu 已提交
42
from .linalg import cov  # noqa: F401
43
from .linalg import corrcoef  # noqa: F401
44
from .linalg import norm  # noqa: F401
45
from .linalg import cond  # noqa: F401
46
from .linalg import transpose  # noqa: F401
47
from .linalg import lstsq  # noqa: F401
48 49 50 51 52 53
from .linalg import dist  # noqa: F401
from .linalg import t  # noqa: F401
from .linalg import cross  # noqa: F401
from .linalg import cholesky  # noqa: F401
from .linalg import bmm  # noqa: F401
from .linalg import histogram  # noqa: F401
S
smallv0221 已提交
54
from .linalg import bincount  # noqa: F401
55
from .linalg import mv  # noqa: F401
L
Lijunhui 已提交
56
from .linalg import eig  # noqa: F401
57
from .linalg import matrix_power  # noqa: F401
58
from .linalg import qr  # noqa: F401
59
from .linalg import eigvals  # noqa: F401
60 61
from .linalg import multi_dot  # noqa: F401
from .linalg import svd  # noqa: F401
62
from .linalg import eigvalsh  # noqa: F401
63
from .linalg import eigh  # noqa: F401
A
andyjpaddle 已提交
64
from .linalg import pinv  # noqa: F401
W
Weilong Wu 已提交
65
from .linalg import solve  # noqa: F401
Z
zhiboniu 已提交
66
from .linalg import cholesky_solve  # noqa: F401
67 68
from .linalg import lu  # noqa: F401
from .linalg import lu_unpack  # noqa: F401
69 70 71 72 73 74 75 76 77 78
from .logic import equal  # noqa: F401
from .logic import greater_equal  # noqa: F401
from .logic import greater_than  # noqa: F401
from .logic import is_empty  # noqa: F401
from .logic import less_equal  # noqa: F401
from .logic import less_than  # noqa: F401
from .logic import logical_and  # noqa: F401
from .logic import logical_not  # noqa: F401
from .logic import logical_or  # noqa: F401
from .logic import logical_xor  # noqa: F401
79 80 81 82
from .logic import bitwise_and  # noqa: F401
from .logic import bitwise_or  # noqa: F401
from .logic import bitwise_xor  # noqa: F401
from .logic import bitwise_not  # noqa: F401
83 84
from .logic import not_equal  # noqa: F401
from .logic import allclose  # noqa: F401
A
andyjpaddle 已提交
85
from .logic import isclose  # noqa: F401
86 87 88 89 90 91
from .logic import equal_all  # noqa: F401
from .logic import is_tensor  # noqa: F401
from .manipulation import cast  # noqa: F401
from .manipulation import concat  # noqa: F401
from .manipulation import expand  # noqa: F401
from .manipulation import broadcast_to  # noqa: F401
92
from .manipulation import broadcast_tensors  # noqa: F401
93 94 95
from .manipulation import expand_as  # noqa: F401
from .manipulation import tile  # noqa: F401
from .manipulation import flatten  # noqa: F401
96
from .manipulation import flatten_  # noqa: F401
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
from .manipulation import gather  # noqa: F401
from .manipulation import gather_nd  # noqa: F401
from .manipulation import reshape  # noqa: F401
from .manipulation import reshape_  # noqa: F401
from .manipulation import flip as reverse  # noqa: F401
from .manipulation import scatter  # noqa: F401
from .manipulation import scatter_  # noqa: F401
from .manipulation import scatter_nd_add  # noqa: F401
from .manipulation import scatter_nd  # noqa: F401
from .manipulation import shard_index  # noqa: F401
from .manipulation import slice  # noqa: F401
from .manipulation import split  # noqa: F401
from .manipulation import squeeze  # noqa: F401
from .manipulation import squeeze_  # noqa: F401
from .manipulation import stack  # noqa: F401
from .manipulation import strided_slice  # noqa: F401
from .manipulation import unique  # noqa: F401
D
duanboqiang 已提交
114
from .manipulation import unique_consecutive  # noqa: F401
115 116 117 118
from .manipulation import unsqueeze  # noqa: F401
from .manipulation import unsqueeze_  # noqa: F401
from .manipulation import unstack  # noqa: F401
from .manipulation import flip  # noqa: F401
Z
zmxdream 已提交
119
from .manipulation import rot90  # noqa: F401
120 121 122
from .manipulation import unbind  # noqa: F401
from .manipulation import roll  # noqa: F401
from .manipulation import chunk  # noqa: F401
F
From00 已提交
123
from .manipulation import tensordot  # noqa: F401
124
from .manipulation import as_complex  # noqa: F401
125
from .manipulation import take_along_axis  # noqa: F401
126 127
from .manipulation import put_along_axis  # noqa: F401
from .manipulation import put_along_axis_  # noqa: F401
128
from .manipulation import as_real  # noqa: F401
129
from .manipulation import moveaxis  # noqa: F401
K
kuizhiqing 已提交
130
from .manipulation import repeat_interleave  # noqa: F401
131 132 133 134 135
from .math import abs  # noqa: F401
from .math import acos  # noqa: F401
from .math import asin  # noqa: F401
from .math import atan  # noqa: F401
from .math import ceil  # noqa: F401
136
from .math import ceil_  # noqa: F401
137 138 139 140
from .math import cos  # noqa: F401
from .math import tan  # noqa: F401
from .math import cosh  # noqa: F401
from .math import cumsum  # noqa: F401
H
hlygit66666 已提交
141
from .math import cumprod  # noqa: F401
W
wangzhen38 已提交
142
from .math import logit  # noqa: F401
143
from .math import exp  # noqa: F401
144
from .math import exp_  # noqa: F401
R
ronnywang 已提交
145
from .math import expm1  # noqa: F401
146
from .math import floor  # noqa: F401
147
from .math import floor_  # noqa: F401
148 149 150 151 152
from .math import increment  # noqa: F401
from .math import log  # noqa: F401
from .math import multiplex  # noqa: F401
from .math import pow  # noqa: F401
from .math import reciprocal  # noqa: F401
153
from .math import reciprocal_  # noqa: F401
154
from .math import round  # noqa: F401
155
from .math import round_  # noqa: F401
156
from .math import rsqrt  # noqa: F401
157
from .math import rsqrt_  # noqa: F401
158
from .math import scale  # noqa: F401
159
from .math import scale_  # noqa: F401
160 161 162 163
from .math import sign  # noqa: F401
from .math import sin  # noqa: F401
from .math import sinh  # noqa: F401
from .math import sqrt  # noqa: F401
164
from .math import sqrt_  # noqa: F401
165 166 167
from .math import square  # noqa: F401
from .math import stanh  # noqa: F401
from .math import sum  # noqa: F401
W
wangguanqun 已提交
168
from .math import nansum  # noqa: F401
169
from .math import nanmean  # noqa: F401
170 171 172 173
from .math import tanh  # noqa: F401
from .math import tanh_  # noqa: F401
from .math import add_n  # noqa: F401
from .math import max  # noqa: F401
T
Tao Luo 已提交
174
from .math import amax  # noqa: F401
175 176
from .math import maximum  # noqa: F401
from .math import min  # noqa: F401
T
Tao Luo 已提交
177
from .math import amin  # noqa: F401
178 179 180 181 182 183 184 185 186
from .math import minimum  # noqa: F401
from .math import mm  # noqa: F401
from .math import divide  # noqa: F401
from .math import floor_divide  # noqa: F401
from .math import remainder  # noqa: F401
from .math import mod  # noqa: F401
from .math import floor_mod  # noqa: F401
from .math import multiply  # noqa: F401
from .math import add  # noqa: F401
187
from .math import add_  # noqa: F401
188
from .math import subtract  # noqa: F401
189
from .math import subtract_  # noqa: F401
R
ronnywang 已提交
190
from .math import atan2  # noqa: F401
191 192 193 194 195 196 197 198
from .math import logsumexp  # noqa: F401
from .math import inverse  # noqa: F401
from .math import log2  # noqa: F401
from .math import log10  # noqa: F401
from .math import log1p  # noqa: F401
from .math import erf  # noqa: F401
from .math import addmm  # noqa: F401
from .math import clip  # noqa: F401
199
from .math import clip_  # noqa: F401
200 201 202 203 204 205 206 207 208 209
from .math import trace  # noqa: F401
from .math import kron  # noqa: F401
from .math import isfinite  # noqa: F401
from .math import isinf  # noqa: F401
from .math import isnan  # noqa: F401
from .math import prod  # noqa: F401
from .math import all  # noqa: F401
from .math import any  # noqa: F401
from .math import broadcast_shape  # noqa: F401
from .math import conj  # noqa: F401
210
from .math import trunc  # noqa: F401
Z
zyfncg 已提交
211
from .math import digamma  # noqa: F401
212 213
from .math import neg  # noqa: F401
from .math import lgamma  # noqa: F401
214
from .math import diagonal  # noqa: F401
X
xiaoting 已提交
215 216 217
from .math import acosh  # noqa: F401
from .math import asinh  # noqa: F401
from .math import atanh  # noqa: F401
218 219
from .math import lerp  # noqa: F401
from .math import lerp_  # noqa: F401
W
wuhuanzhou 已提交
220 221
from .math import erfinv  # noqa: F401
from .math import erfinv_  # noqa: F401
222 223
from .math import rad2deg  # noqa: F401
from .math import deg2rad  # noqa: F401
T
Tao Luo 已提交
224 225
from .math import gcd  # noqa: F401
from .math import lcm  # noqa: F401
A
andyjpaddle 已提交
226
from .math import diff  # noqa: F401
F
Feiyu Chan 已提交
227
from .math import angle  # noqa: F401
L
LJQ❤️ 已提交
228 229
from .math import fmax  # noqa: F401
from .math import fmin  # noqa: F401
Z
zhiboniu 已提交
230 231
from .math import inner  # noqa: F401
from .math import outer  # noqa: F401
232
from .math import heaviside  # noqa: F401
233
from .math import frac  # noqa: F401
234

235 236 237 238
from .random import multinomial  # noqa: F401
from .random import standard_normal  # noqa: F401
from .random import normal  # noqa: F401
from .random import uniform  # noqa: F401
J
JYChen 已提交
239
from .random import uniform_  # noqa: F401
240 241 242
from .random import randn  # noqa: F401
from .random import rand  # noqa: F401
from .random import randint  # noqa: F401
243
from .random import randint_like  # noqa: F401
244
from .random import randperm  # noqa: F401
245
from .random import poisson  # noqa: F401
246
from .random import exponential_  # noqa: F401
247 248 249
from .search import argmax  # noqa: F401
from .search import argmin  # noqa: F401
from .search import argsort  # noqa: F401
Y
Yanxing Shi 已提交
250
from .search import searchsorted  # noqa: F401
251 252 253 254 255 256 257
from .search import topk  # noqa: F401
from .search import where  # noqa: F401
from .search import index_select  # noqa: F401
from .search import nonzero  # noqa: F401
from .search import sort  # noqa: F401
from .search import index_sample  # noqa: F401
from .search import masked_select  # noqa: F401
258
from .search import kthvalue  # noqa: F401
259 260
from .search import mode  # noqa: F401

261 262 263 264 265
from .stat import mean  # noqa: F401
from .stat import std  # noqa: F401
from .stat import var  # noqa: F401
from .stat import numel  # noqa: F401
from .stat import median  # noqa: F401
266
from .stat import nanmedian  # noqa: F401
267
from .stat import quantile  # noqa: F401
268
from .stat import nanquantile  # noqa: F401
269

270
from .to_string import set_printoptions  # noqa: F401
271

272 273 274 275
from .array import array_length  # noqa: F401
from .array import array_read  # noqa: F401
from .array import array_write  # noqa: F401
from .array import create_array  # noqa: F401
L
Leo Chen 已提交
276

T
Tongxin Bai 已提交
277 278
from .einsum import einsum  # noqa: F401

279 280 281 282
#this list used in math_op_patch.py for _binary_creator_
tensor_method_func  = [ #noqa
           'matmul',
           'dot',
Z
zhiboniu 已提交
283
           'cov',
284
           'corrcoef',
285
           'norm',
286
           'cond',
287
           'transpose',
288
           'lstsq',
289 290 291 292 293 294
           'dist',
           't',
           'cross',
           'cholesky',
           'bmm',
           'histogram',
S
smallv0221 已提交
295
           'bincount',
296
           'mv',
297
           'matrix_power',
298
           'qr',
299
           'eigvals',
300
           'eigvalsh',
301 302 303 304 305 306 307
           'abs',
           'acos',
           'all',
           'any',
           'asin',
           'atan',
           'ceil',
308
           'ceil_',
309 310 311
           'cos',
           'cosh',
           'cumsum',
H
hlygit66666 已提交
312
           'cumprod',
W
wangzhen38 已提交
313
           'logit',
314
           'exp',
315
           'exp_',
316
           'floor',
317
           'floor_',
318 319 320 321 322 323 324 325 326
           'increment',
           'log',
           'log2',
           'log10',
           'logsumexp',
           'multiplex',
           'pow',
           'prod',
           'reciprocal',
327
           'reciprocal_',
328
           'round',
329
           'round_',
330
           'rsqrt',
331
           'rsqrt_',
332
           'scale',
333
           'scale_',
334 335 336 337
           'sign',
           'sin',
           'sinh',
           'sqrt',
338
           'sqrt_',
339 340 341
           'square',
           'stanh',
           'sum',
W
wangguanqun 已提交
342
           'nansum',
343
           'nanmean',
344 345 346 347
           'tanh',
           'tanh_',
           'add_n',
           'max',
T
Tao Luo 已提交
348
           'amax',
349 350
           'maximum',
           'min',
T
Tao Luo 已提交
351
           'amin',
352
           'minimum',
L
LJQ❤️ 已提交
353 354
           'fmax',
           'fmin',
355
           'mm',
Z
zhiboniu 已提交
356 357
           'inner',
           'outer',
358 359 360 361 362 363 364
           'divide',
           'floor_divide',
           'remainder',
           'mod',
           'floor_mod',
           'multiply',
           'add',
365
           'add_',
366
           'subtract',
367
           'subtract_',
368 369 370 371 372 373 374
           'atan',
           'logsumexp',
           'inverse',
           'log1p',
           'erf',
           'addmm',
           'clip',
375
           'clip_',
376 377
           'trace',
           'kron',
378
           'kthvalue',
379 380 381 382 383
           'isfinite',
           'isinf',
           'isnan',
           'broadcast_shape',
           'conj',
384 385
           'neg',
           'lgamma',
386 387 388 389 390 391 392 393 394 395 396 397 398
           'equal',
           'equal_all',
           'greater_equal',
           'greater_than',
           'is_empty',
           'less_equal',
           'less_than',
           'logical_and',
           'logical_not',
           'logical_or',
           'logical_xor',
           'not_equal',
           'allclose',
A
andyjpaddle 已提交
399
           'isclose',
400 401 402 403 404 405 406
           'is_tensor',
           'cast',
           'concat',
           'expand',
           'broadcast_to',
           'expand_as',
           'flatten',
407
           'flatten_',
408 409 410 411 412 413 414 415 416 417 418 419 420
           'gather',
           'gather_nd',
           'reshape',
           'reshape_',
           'reverse',
           'scatter',
           'scatter_',
           'scatter_nd_add',
           'scatter_nd',
           'shard_index',
           'slice',
           'split',
           'chunk',
F
From00 已提交
421
           'tensordot',
422 423 424 425 426 427
           'squeeze',
           'squeeze_',
           'stack',
           'strided_slice',
           'transpose',
           'unique',
D
duanboqiang 已提交
428
           'unique_consecutive',
429 430 431 432
           'unsqueeze',
           'unsqueeze_',
           'unstack',
           'flip',
Z
zmxdream 已提交
433
           'rot90',
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451
           'unbind',
           'roll',
           'tile',
           'argmax',
           'argmin',
           'argsort',
           'masked_select',
           'topk',
           'where',
           'index_select',
           'nonzero',
           'sort',
           'index_sample',
           'mean',
           'std',
           'var',
           'numel',
           'median',
452
           'nanmedian',
453
           'quantile',
454
           'nanquantile',
455 456
           'is_complex',
           'is_integer',
457 458 459
           'rank',
           'shape',
           'real',
Z
zyfncg 已提交
460
           'imag',
W
wuhuanzhou 已提交
461
           'is_floating_point',
462
           'digamma',
463 464
           'diagonal',
           'trunc',
465
           'frac',
466 467 468 469
           'bitwise_and',
           'bitwise_or',
           'bitwise_xor',
           'bitwise_not',
470
           'broadcast_tensors',
L
Lijunhui 已提交
471
           'eig',
J
JYChen 已提交
472
           'uniform_',
473
           'multi_dot',
W
Weilong Wu 已提交
474
           'solve',
Z
zhiboniu 已提交
475
           'cholesky_solve',
A
andyjpaddle 已提交
476
           'triangular_solve',
X
xiaoting 已提交
477 478 479
           'asinh',
           'atanh',
           'acosh',
480 481
           'lu',
           'lu_unpack',
482 483
           'as_complex',
           'as_real',
T
Tao Luo 已提交
484 485 486 487
           'rad2deg',
           'deg2rad',
           'gcd',
           'lcm',
F
Feiyu Chan 已提交
488
           'diff',
489
           "mode",
490 491
           'lerp',
           'lerp_',
W
wuhuanzhou 已提交
492 493
           'erfinv',
           'erfinv_',
F
Feiyu Chan 已提交
494
           'angle',
K
kuizhiqing 已提交
495 496
           'moveaxis',
           'repeat_interleave',
497
           'take_along_axis',
498 499
           'put_along_axis',
           'put_along_axis_',
500
           'exponential_',
501
           'heaviside',
502 503 504 505 506 507 508 509
]

#this list used in math_op_patch.py for magic_method bind
magic_method_func = [
    ('__and__', 'bitwise_and'),
    ('__or__', 'bitwise_or'),
    ('__xor__', 'bitwise_xor'),
    ('__invert__', 'bitwise_not'),
510
]