Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wmsofts
Paddle
提交
60d1199a
P
Paddle
项目概览
wmsofts
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
60d1199a
编写于
1月 18, 2023
作者:
H
houj04
提交者:
GitHub
1月 18, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[XPU] add logical_not op. (#49911)
上级
4c8c5b4b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
63 addition
and
8 deletion
+63
-8
paddle/phi/backends/xpu/xpu2_op_list.cc
paddle/phi/backends/xpu/xpu2_op_list.cc
+1
-0
paddle/phi/kernels/xpu/logical_kernel.cc
paddle/phi/kernels/xpu/logical_kernel.cc
+33
-0
python/paddle/fluid/tests/unittests/xpu/get_test_cover_info.py
...n/paddle/fluid/tests/unittests/xpu/get_test_cover_info.py
+2
-1
python/paddle/fluid/tests/unittests/xpu/test_logical_op_xpu.py
...n/paddle/fluid/tests/unittests/xpu/test_logical_op_xpu.py
+27
-7
未找到文件。
paddle/phi/backends/xpu/xpu2_op_list.cc
浏览文件 @
60d1199a
...
...
@@ -360,6 +360,7 @@ XPUOpMap& get_kl2_ops() {
{
"log_grad"
,
XPUKernelSet
({
phi
::
DataType
::
FLOAT32
})},
{
"log_softmax"
,
XPUKernelSet
({
phi
::
DataType
::
FLOAT32
})},
{
"log_softmax_grad"
,
XPUKernelSet
({
phi
::
DataType
::
FLOAT32
})},
{
"logical_not"
,
XPUKernelSet
({
phi
::
DataType
::
BOOL
})},
{
"lookup_table_v2_grad"
,
XPUKernelSet
({
phi
::
DataType
::
FLOAT32
})},
{
"lookup_table_v2"
,
XPUKernelSet
({
phi
::
DataType
::
FLOAT32
})},
{
"masked_select"
,
...
...
paddle/phi/kernels/xpu/logical_kernel.cc
0 → 100644
浏览文件 @
60d1199a
// Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
//
// 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.
#include "paddle/phi/kernels/logical_kernel.h"
#include "paddle/phi/backends/xpu/enforce_xpu.h"
#include "paddle/phi/core/kernel_registry.h"
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
LogicalNotKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
x
,
DenseTensor
*
out
)
{
ctx
.
template
Alloc
<
T
>(
out
);
int
r
=
xpu
::
logical_not
(
ctx
.
x_context
(),
x
.
data
<
T
>
(),
out
->
data
<
T
>
(),
x
.
numel
());
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"logical_not"
);
}
}
// namespace phi
PD_REGISTER_KERNEL
(
logical_not
,
XPU
,
ALL_LAYOUT
,
phi
::
LogicalNotKernel
,
bool
)
{}
python/paddle/fluid/tests/unittests/xpu/get_test_cover_info.py
浏览文件 @
60d1199a
...
...
@@ -228,7 +228,8 @@ def get_xpu_op_support_types(op_name, dev_id=0):
op_name_type
=
op_name
+
"_"
+
stype
if
op_name_type
in
ops
:
support_types
.
append
(
stype
)
if
len
(
support_types
)
==
0
:
print
(
"WARNING: support_types is EMPTY for op"
,
op_name
)
return
support_types
...
...
python/paddle/fluid/tests/unittests/xpu/test_logical_op_xpu.py
浏览文件 @
60d1199a
...
...
@@ -46,6 +46,11 @@ class XPUTestLogicalAnd(XPUOpTestWrapper):
def
set_case
(
self
):
self
.
op_type
=
'logical_and'
# special range for bool dtype
if
self
.
dtype
==
np
.
dtype
(
np
.
bool
):
self
.
low
=
0
self
.
high
=
2
x
=
np
.
random
.
randint
(
self
.
low
,
self
.
high
,
self
.
x_shape
,
dtype
=
self
.
dtype
)
...
...
@@ -62,7 +67,7 @@ class XPUTestLogicalAnd(XPUOpTestWrapper):
self
.
outputs
=
{
'Out'
:
out
}
def
init_case
(
self
):
self
.
dtype
=
np
.
int32
self
.
dtype
=
self
.
in_type
self
.
x_shape
=
[
2
,
3
,
4
,
5
]
self
.
y_shape
=
[
2
,
3
,
4
,
5
]
self
.
low
=
-
100
...
...
@@ -76,7 +81,7 @@ class XPUTestLogicalAnd(XPUOpTestWrapper):
class
XPUTestLogicalAndCase1
(
XPUTestLogicalAndBase
):
def
init_case
(
self
):
self
.
dtype
=
np
.
int32
self
.
dtype
=
self
.
in_type
self
.
x_shape
=
[
4
,
5
]
self
.
y_shape
=
[
2
,
3
,
4
,
5
]
self
.
low
=
-
100
...
...
@@ -102,6 +107,11 @@ class XPUTestLogicalOr(XPUOpTestWrapper):
def
set_case
(
self
):
self
.
op_type
=
'logical_or'
# special range for bool dtype
if
self
.
dtype
==
np
.
dtype
(
np
.
bool
):
self
.
low
=
0
self
.
high
=
2
x
=
np
.
random
.
randint
(
self
.
low
,
self
.
high
,
self
.
x_shape
,
dtype
=
self
.
dtype
)
...
...
@@ -118,7 +128,7 @@ class XPUTestLogicalOr(XPUOpTestWrapper):
self
.
outputs
=
{
'Out'
:
out
}
def
init_case
(
self
):
self
.
dtype
=
np
.
int32
self
.
dtype
=
self
.
in_type
self
.
x_shape
=
[
2
,
3
,
4
,
5
]
self
.
y_shape
=
[
2
,
3
,
4
,
5
]
self
.
low
=
-
100
...
...
@@ -132,7 +142,7 @@ class XPUTestLogicalOr(XPUOpTestWrapper):
class
XPUTestLogicalOrCase1
(
XPUTestLogicalOrBase
):
def
init_case
(
self
):
self
.
dtype
=
np
.
int32
self
.
dtype
=
self
.
in_type
self
.
x_shape
=
[
4
,
5
]
self
.
y_shape
=
[
2
,
3
,
4
,
5
]
self
.
low
=
-
100
...
...
@@ -158,6 +168,11 @@ class XPUTestLogicalXor(XPUOpTestWrapper):
def
set_case
(
self
):
self
.
op_type
=
'logical_xor'
# special range for bool dtype
if
self
.
dtype
==
np
.
dtype
(
np
.
bool
):
self
.
low
=
0
self
.
high
=
2
x
=
np
.
random
.
randint
(
self
.
low
,
self
.
high
,
self
.
x_shape
,
dtype
=
self
.
dtype
)
...
...
@@ -174,7 +189,7 @@ class XPUTestLogicalXor(XPUOpTestWrapper):
self
.
outputs
=
{
'Out'
:
out
}
def
init_case
(
self
):
self
.
dtype
=
np
.
int64
self
.
dtype
=
self
.
in_type
self
.
x_shape
=
[
2
,
3
,
4
,
5
]
self
.
y_shape
=
[
2
,
3
,
4
,
5
]
self
.
low
=
-
100
...
...
@@ -188,7 +203,7 @@ class XPUTestLogicalXor(XPUOpTestWrapper):
class
XPUTestLogicalXorCase1
(
XPUTestLogicalXorBase
):
def
init_case
(
self
):
self
.
dtype
=
np
.
int32
self
.
dtype
=
self
.
in_type
self
.
x_shape
=
[
4
,
5
]
self
.
y_shape
=
[
2
,
3
,
4
,
5
]
self
.
low
=
-
100
...
...
@@ -214,6 +229,11 @@ class XPUTestLogicalNot(XPUOpTestWrapper):
def
set_case
(
self
):
self
.
op_type
=
'logical_not'
# special range for bool dtype
if
self
.
dtype
==
np
.
dtype
(
np
.
bool
):
self
.
low
=
0
self
.
high
=
2
x
=
np
.
random
.
randint
(
self
.
low
,
self
.
high
,
self
.
x_shape
,
dtype
=
self
.
dtype
)
...
...
@@ -224,7 +244,7 @@ class XPUTestLogicalNot(XPUOpTestWrapper):
self
.
outputs
=
{
'Out'
:
out
}
def
init_case
(
self
):
self
.
dtype
=
np
.
int32
self
.
dtype
=
self
.
in_type
self
.
x_shape
=
[
2
,
3
,
4
,
5
]
self
.
low
=
-
100
self
.
high
=
100
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录