@@ -24,7 +24,7 @@ $\gamma(a, x) = \int_0^x t^{a-1} e^{-t} dt $
24
24
上不完全伽马函数 $\Gamma(a,x)$ 的定义域为 $a>0$, $x \geq 0$,值域为 $(0,\Gamma(a)] $。
25
25
下不完全伽马函数 $\gamma(a,x)$ 的定义域为 $a>0$, $x \geq 0$,值域为 $[ 0,\Gamma(a))$,其中 $\Gamma(a)$ 是伽马函数的值。
26
26
27
- 相应的 API 需要输入两个参数 ` input ` 与 ` other ` ,对应上式的 $a $ 和 $x $;
27
+ 相应的 API 需要输入两个参数 ` x ` 与 ` a ` ,对应上式的 $x $ 和 $a $;
28
28
29
29
## 3、意义
30
30
@@ -364,64 +364,64 @@ XlaOp Igamma(XlaOp a, XlaOp x) {
364
364
365
365
```python
366
366
paddle.igamma(
367
- input : Tensor,
368
- other : Tensor,
367
+ x : Tensor,
368
+ a : Tensor,
369
369
name: str | None = None
370
370
)
371
371
```
372
372
373
373
``` python
374
374
paddle.igammac(
375
- input : Tensor,
376
- other : Tensor,
375
+ x : Tensor,
376
+ a : Tensor,
377
377
name: str | None = None
378
378
)
379
379
```
380
380
381
381
``` python
382
382
paddle.igamma_(
383
- input : Tensor,
384
- other : Tensor,
383
+ x : Tensor,
384
+ a : Tensor,
385
385
name: str | None = None
386
386
)
387
387
```
388
388
389
389
``` python
390
390
paddle.igammac_(
391
- input : Tensor,
392
- other : Tensor,
391
+ x : Tensor,
392
+ a : Tensor,
393
393
name: str | None = None
394
394
)
395
395
```
396
396
397
397
``` python
398
398
paddle.Tensor.igamma(
399
- other : Tensor
399
+ a : Tensor
400
400
)
401
401
```
402
402
403
403
``` python
404
404
paddle.Tensor.igammac(
405
- other : Tensor
405
+ a : Tensor
406
406
)
407
407
```
408
408
409
409
``` python
410
410
paddle.Tensor.igamma_(
411
- other : Tensor
411
+ a : Tensor
412
412
)
413
413
```
414
414
415
415
``` python
416
416
paddle.Tensor.igammac_(
417
- other : Tensor
417
+ a : Tensor
418
418
)
419
419
```
420
420
421
421
## 底层OP设计
422
422
Kernel部分CPU实现添加在 ` paddle/phi/kernels/cpu/igamma_kernel.cc ` 和 ` paddle/phi/kernels/cpu/igammac_kernel.cc ` ,
423
423
Kernel部分GPU实现添加在 ` paddle/phi/kernels/gpu/igamma_kernel.cu ` 和 ` paddle/phi/kernels/gpu/igammac_kernel.cu ` ,
424
- 输入 CPU 支持 float16, bfloat16, float32, float64,GPU支持 float32, float64,
424
+ 输入支持 float32, float64,
425
425
对于底层 OP 主要分为三部分,由于 ` igamma ` 和 ` igammac ` 是互补关系,所以实际上可复用代码很多,
426
426
因此底层OP设计仅以` igammac ` 为例。
427
427
@@ -444,10 +444,10 @@ $\Gamma(a, x) = \int_x^{\infty} t^{a-1} e^{-t} dt $
444
444
### igamma
445
445
对于 igamma 、 igamma_ 、igammac 和 igammac_ 有类似的API,下面列出了` igamma ` 的情况。
446
446
447
- 具体的API为` paddle.igamma(input, other , name = None) ` 和` paddle.Tensor.igamma(input, other ) `
447
+ 具体的API为` paddle.igamma(x, a , name = None) ` 和` paddle.Tensor.igamma(x, a ) `
448
448
449
- - input : 输入张量,即公式中的 $a $, CPU 支持 float16, bfloat16, float32, float64,GPU支持 float32, float64
450
- - other : 输入张量,即公式中的 $x $, CPU 支持 float16, bfloat16, float32, float64,GPU支持 float32, float64
449
+ - x : 输入张量,即公式中的 $x $, 支持 float32, float64
450
+ - a : 输入张量,即公式中的 $a $, 支持 float32, float64
451
451
452
452
453
453
例如将一维张量 $[ 3, 5] $ 和一维张量 $[ 2, 7] $ 输入,则计算结果如下:
@@ -460,7 +460,7 @@ $\Gamma(a, x) = [\int_2^{\infty} t^{2} e^{-t} dt, \int_7^{\infty} t^{4} e^{-t} d
460
460
测试需要考虑的 case 如下:
461
461
462
462
- 输出数值结果的一致性和数据类型是否正确,使用 scipy 作为参考标准
463
- - 对不同 dtype 的输入数据 ` input ` 和 ` other ` 进行计算精度检验,与PyTorch保持一致
463
+ - 对不同 dtype 的输入数据 ` x ` 和 ` a ` 进行计算精度检验,与PyTorch保持一致
464
464
- 输入输出的容错性与错误提示信息
465
465
- 输出 Dtype 错误或不兼容时抛出异常
466
466
- 保证调用属性时是可以被正常找到的
0 commit comments