Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c284d42a
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
未验证
提交
c284d42a
编写于
2月 16, 2023
作者:
C
Chen Weihang
提交者:
GitHub
2月 16, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add logspace yaml (#49194)
* add logspace yaml * update by comments * resolve test framework conflicct
上级
aded3338
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
34 addition
and
37 deletion
+34
-37
paddle/phi/api/yaml/legacy_ops.yaml
paddle/phi/api/yaml/legacy_ops.yaml
+12
-0
paddle/phi/infermeta/multiary.cc
paddle/phi/infermeta/multiary.cc
+2
-1
paddle/phi/infermeta/multiary.h
paddle/phi/infermeta/multiary.h
+1
-0
python/paddle/fluid/tests/unittests/test_logspace.py
python/paddle/fluid/tests/unittests/test_logspace.py
+11
-33
python/paddle/tensor/creation.py
python/paddle/tensor/creation.py
+8
-3
未找到文件。
paddle/phi/api/yaml/legacy_ops.yaml
浏览文件 @
c284d42a
...
...
@@ -1031,6 +1031,18 @@
kernel
:
func
:
logical_xor
-
op
:
logspace
args
:
(Tensor start, Tensor stop, Tensor num, Tensor base, DataType dtype, Place place={})
output
:
Tensor(out)
infer_meta
:
func
:
LogspaceInferMeta
param
:
[
start
,
stop
,
num
,
base
,
dtype
]
kernel
:
func
:
logspace
param
:
[
start
,
stop
,
num
,
base
,
dtype
]
data_type
:
dtype
backend
:
place
-
op
:
logsumexp
args
:
(Tensor x, int64_t[] axis, bool keepdim, bool reduce_all)
output
:
Tensor(out)
...
...
paddle/phi/infermeta/multiary.cc
浏览文件 @
c284d42a
...
...
@@ -1972,6 +1972,7 @@ void LogspaceInferMeta(const MetaTensor& start,
const
MetaTensor
&
stop
,
const
MetaTensor
&
number
,
const
MetaTensor
&
base
,
DataType
dtype
,
MetaTensor
*
out
)
{
auto
s_dims
=
start
.
dims
();
PADDLE_ENFORCE_EQ
(
...
...
@@ -2002,7 +2003,7 @@ void LogspaceInferMeta(const MetaTensor& start,
"but received input shape is [%s]."
,
b_dims
));
out
->
set_dims
(
phi
::
make_ddim
({
-
1
}));
out
->
set_dtype
(
start
.
dtype
()
);
out
->
set_dtype
(
dtype
);
}
void
MergedAdamInferMeta
(
...
...
paddle/phi/infermeta/multiary.h
浏览文件 @
c284d42a
...
...
@@ -341,6 +341,7 @@ void LogspaceInferMeta(const MetaTensor& start,
const
MetaTensor
&
stop
,
const
MetaTensor
&
number
,
const
MetaTensor
&
base
,
DataType
dtype
,
MetaTensor
*
out
);
void
MergedAdamInferMeta
(
...
...
python/paddle/fluid/tests/unittests/test_logspace.py
浏览文件 @
c284d42a
...
...
@@ -24,6 +24,9 @@ class TestLogspaceOpCommonCase(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"logspace"
self
.
python_api
=
paddle
.
logspace
self
.
init_data
()
def
init_data
(
self
):
dtype
=
'float32'
self
.
inputs
=
{
'Start'
:
np
.
array
([
0
]).
astype
(
dtype
),
...
...
@@ -32,17 +35,14 @@ class TestLogspaceOpCommonCase(OpTest):
'Base'
:
np
.
array
([
2
]).
astype
(
dtype
),
}
self
.
attrs
=
{
'dtype'
:
int
(
paddle
.
float32
)}
self
.
outputs
=
{
'Out'
:
np
.
power
(
2
,
np
.
arange
(
0
,
11
)).
astype
(
dtype
)}
def
test_check_output
(
self
):
self
.
check_output
()
class
TestLogspaceOpReverseCase
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"logspace"
self
.
python_api
=
paddle
.
logspace
class
TestLogspaceOpReverseCase
(
TestLogspaceOpCommonCase
):
def
init_data
(
self
):
dtype
=
'float32'
self
.
inputs
=
{
'Start'
:
np
.
array
([
10
]).
astype
(
dtype
),
...
...
@@ -51,17 +51,11 @@ class TestLogspaceOpReverseCase(OpTest):
'Base'
:
np
.
array
([
2
]).
astype
(
dtype
),
}
self
.
attrs
=
{
'dtype'
:
int
(
paddle
.
float32
)}
self
.
outputs
=
{
'Out'
:
np
.
power
(
2
,
np
.
arange
(
10
,
-
1
,
-
1
)).
astype
(
dtype
)}
def
test_check_output
(
self
):
self
.
check_output
()
class
TestLogspaceOpNumOneCase
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"logspace"
self
.
python_api
=
paddle
.
logspace
class
TestLogspaceOpNumOneCase
(
TestLogspaceOpCommonCase
):
def
init_data
(
self
):
dtype
=
'float32'
self
.
inputs
=
{
'Start'
:
np
.
array
([
10
]).
astype
(
dtype
),
...
...
@@ -70,17 +64,11 @@ class TestLogspaceOpNumOneCase(OpTest):
'Base'
:
np
.
array
([
2
]).
astype
(
dtype
),
}
self
.
attrs
=
{
'dtype'
:
int
(
paddle
.
float32
)}
self
.
outputs
=
{
'Out'
:
np
.
power
(
2
,
np
.
array
(
10
)).
astype
(
dtype
)}
def
test_check_output
(
self
):
self
.
check_output
()
class
TestLogspaceOpMinusBaseCase
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"logspace"
self
.
python_api
=
paddle
.
logspace
class
TestLogspaceOpMinusBaseCase
(
TestLogspaceOpCommonCase
):
def
init_data
(
self
):
dtype
=
'float32'
self
.
inputs
=
{
'Start'
:
np
.
array
([
0
]).
astype
(
dtype
),
...
...
@@ -89,17 +77,11 @@ class TestLogspaceOpMinusBaseCase(OpTest):
'Base'
:
np
.
array
([
-
2
]).
astype
(
dtype
),
}
self
.
attrs
=
{
'dtype'
:
int
(
paddle
.
float32
)}
self
.
outputs
=
{
'Out'
:
np
.
power
(
-
2
,
np
.
arange
(
0
,
11
)).
astype
(
dtype
)}
def
test_check_output
(
self
):
self
.
check_output
()
class
TestLogspaceOpZeroBaseCase
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"logspace"
self
.
python_api
=
paddle
.
logspace
class
TestLogspaceOpZeroBaseCase
(
TestLogspaceOpCommonCase
):
def
init_data
(
self
):
dtype
=
'float32'
self
.
inputs
=
{
'Start'
:
np
.
array
([
0
]).
astype
(
dtype
),
...
...
@@ -108,12 +90,8 @@ class TestLogspaceOpZeroBaseCase(OpTest):
'Base'
:
np
.
array
([
0
]).
astype
(
dtype
),
}
self
.
attrs
=
{
'dtype'
:
int
(
paddle
.
float32
)}
self
.
outputs
=
{
'Out'
:
np
.
power
(
0
,
np
.
arange
(
0
,
11
)).
astype
(
dtype
)}
def
test_check_output
(
self
):
self
.
check_output
()
class
TestLogspaceAPI
(
unittest
.
TestCase
):
def
test_variable_input1
(
self
):
...
...
python/paddle/tensor/creation.py
浏览文件 @
c284d42a
...
...
@@ -21,7 +21,7 @@ import warnings
import
numpy
as
np
import
paddle
from
paddle
import
_C_ops
,
_legacy_C_ops
from
paddle
import
_C_ops
from
paddle.common_ops_import
import
fill_constant
from
..fluid.data_feeder
import
(
...
...
@@ -447,8 +447,13 @@ def logspace(start, stop, num, base=10.0, dtype=None, name=None):
with
device_guard
(
"cpu"
):
tensor_base
=
fill_constant
([
1
],
dtype
,
base
)
if
in_dygraph_mode
():
return
_legacy_C_ops
.
logspace
(
tensor_start
,
tensor_stop
,
tensor_num
,
tensor_base
,
'dtype'
,
dtype
return
_C_ops
.
logspace
(
tensor_start
,
tensor_stop
,
tensor_num
,
tensor_base
,
dtype
,
_current_expected_place
(),
)
else
:
helper
=
LayerHelper
(
"logspace"
,
**
locals
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录