Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
920c66e9
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
920c66e9
编写于
8月 17, 2023
作者:
H
huangjiyi
提交者:
GitHub
8月 17, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【complex op】 No.34 add complex support for dot (#56349)
* update * fix codestyle * update * update
上级
488071af
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
92 deletion
+44
-92
python/paddle/tensor/linalg.py
python/paddle/tensor/linalg.py
+22
-4
test/legacy_test/test_dot_op.py
test/legacy_test/test_dot_op.py
+22
-88
未找到文件。
python/paddle/tensor/linalg.py
浏览文件 @
920c66e9
...
...
@@ -1080,8 +1080,8 @@ def dot(x, y, name=None):
is the batch dimension, which means that the vectors of multiple batches are dotted.
Parameters:
x(Tensor): 1-D or 2-D ``Tensor``. Its dtype should be ``float32``, ``float64``, ``int32``, ``int64``
y(Tensor): 1-D or 2-D ``Tensor``. Its dtype soulde be ``float32``, ``float64``, ``int32``, ``int64``
x(Tensor): 1-D or 2-D ``Tensor``. Its dtype should be ``float32``, ``float64``, ``int32``, ``int64``
, ``complex64``, ``complex128``
y(Tensor): 1-D or 2-D ``Tensor``. Its dtype soulde be ``float32``, ``float64``, ``int32``, ``int64``
, ``complex64``, ``complex128``
name(str, optional): Name of the output. Default is None. It's used to print debug info for developers. Details: :ref:`api_guide_Name`
Returns:
...
...
@@ -1117,13 +1117,31 @@ def dot(x, y, name=None):
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'uint16'
,
'float32'
,
'float64'
,
'int32'
,
'int64'
],
[
'float16'
,
'uint16'
,
'float32'
,
'float64'
,
'int32'
,
'int64'
,
'complex64'
,
'complex128'
,
],
op_type
,
)
check_variable_and_dtype
(
y
,
'y'
,
[
'float16'
,
'uint16'
,
'float32'
,
'float64'
,
'int32'
,
'int64'
],
[
'float16'
,
'uint16'
,
'float32'
,
'float64'
,
'int32'
,
'int64'
,
'complex64'
,
'complex128'
,
],
op_type
,
)
...
...
test/legacy_test/test_dot_op.py
浏览文件 @
920c66e9
...
...
@@ -182,102 +182,36 @@ class TestDygraph(unittest.TestCase):
)
class
TestComplexDotOp
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"dot"
self
.
python_api
=
paddle
.
dot
self
.
init_base_dtype
()
self
.
init_input_output
()
self
.
inputs
=
{
'X'
:
OpTest
.
np_dtype_to_fluid_dtype
(
self
.
x
),
'Y'
:
OpTest
.
np_dtype_to_fluid_dtype
(
self
.
y
),
}
self
.
outputs
=
{
'Out'
:
self
.
out
}
def
init_base_dtype
(
self
):
self
.
dtype
=
np
.
float64
class
TestComplex64DotOp
(
DotOp
):
def
init_dtype
(
self
):
self
.
dtype
=
np
.
complex64
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
random
(
100
).
astype
(
self
.
dtype
)
+
1j
*
np
.
random
.
random
(
100
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
random
(
100
).
astype
(
self
.
dtype
)
+
1j
*
np
.
random
.
random
(
100
).
astype
(
self
.
dtype
)
self
.
out
=
np
.
dot
(
self
.
x
,
self
.
y
)
def
test_check_output
(
self
):
self
.
check_output
()
def
test_check_grad_normal
(
self
):
self
.
check_grad
(
[
'X'
,
'Y'
],
'Out'
,
)
def
test_check_grad_ingore_x
(
self
):
self
.
check_grad
(
[
'Y'
],
'Out'
,
no_grad_set
=
set
(
"X"
),
)
def
test_check_grad_ingore_y
(
self
):
self
.
check_grad
(
[
'X'
],
'Out'
,
no_grad_set
=
set
(
'Y'
),
)
class
TestComplexDotOp2D
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"dot"
self
.
python_api
=
paddle
.
dot
self
.
init_base_dtype
()
self
.
init_input_output
()
self
.
inputs
=
{
'X'
:
OpTest
.
np_dtype_to_fluid_dtype
(
self
.
x
),
'Y'
:
OpTest
.
np_dtype_to_fluid_dtype
(
self
.
y
),
}
self
.
outputs
=
{
'Out'
:
self
.
out
}
shape
=
100
self
.
x
=
(
np
.
random
.
random
(
shape
)
+
1j
*
np
.
random
.
random
(
shape
)
).
astype
(
self
.
dtype
)
self
.
y
=
(
np
.
random
.
random
(
shape
)
+
1j
*
np
.
random
.
random
(
shape
)
).
astype
(
self
.
dtype
)
self
.
out
=
np
.
dot
(
self
.
x
,
self
.
y
).
astype
(
self
.
dtype
)
def
init_base_dtype
(
self
):
self
.
dtype
=
np
.
float64
class
TestComplex64DotOp2D
(
TestComplex64DotOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
random
((
2
,
100
)).
astype
(
self
.
dtype
)
+
1j
*
np
.
random
.
random
((
2
,
100
)).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
random
((
2
,
100
)).
astype
(
self
.
dtype
)
+
1j
*
np
.
random
.
random
((
2
,
100
)).
astype
(
self
.
dtype
)
shape
=
(
2
,
100
)
self
.
x
=
(
np
.
random
.
random
(
shape
)
+
1j
*
np
.
random
.
random
(
shape
)
).
astype
(
self
.
dtype
)
self
.
y
=
(
np
.
random
.
random
(
shape
)
+
1j
*
np
.
random
.
random
(
shape
)
).
astype
(
self
.
dtype
)
self
.
out
=
np
.
diag
(
np
.
dot
(
self
.
x
,
self
.
y
.
T
)).
reshape
(
-
1
)
def
test_check_output
(
self
):
self
.
check_output
()
def
test_check_grad_normal
(
self
):
self
.
check_grad
(
[
'X'
,
'Y'
],
'Out'
,
)
def
test_check_grad_ingore_x
(
self
):
self
.
check_grad
(
[
'Y'
],
'Out'
,
no_grad_set
=
set
(
"X"
),
)
def
test_check_grad_ingore_y
(
self
):
self
.
check_grad
(
[
'X'
],
'Out'
,
no_grad_set
=
set
(
'Y'
),
)
class
TestComplex128DotOp
(
TestComplex64DotOp
):
def
init_dtype
(
self
):
self
.
dtype
=
np
.
complex128
@
unittest
.
skipIf
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录