Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
d394c9ed
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看板
未验证
提交
d394c9ed
编写于
4月 06, 2023
作者:
R
RedContritio
提交者:
GitHub
4月 06, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support auto generate static for assign_value (#52534)
上级
c1f97a9b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
97 deletion
+16
-97
paddle/fluid/operators/assign_value_op.cc
paddle/fluid/operators/assign_value_op.cc
+0
-97
paddle/phi/api/yaml/op_compat.yaml
paddle/phi/api/yaml/op_compat.yaml
+5
-0
paddle/phi/api/yaml/static_ops.yaml
paddle/phi/api/yaml/static_ops.yaml
+11
-0
未找到文件。
paddle/fluid/operators/assign_value_op.cc
已删除
100644 → 0
浏览文件 @
c1f97a9b
// Copyright (c) 2018 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/fluid/operators/assign_value_op.h"
#include <string>
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/phi/core/infermeta_utils.h"
#include "paddle/phi/infermeta/nullary.h"
namespace
paddle
{
namespace
framework
{
class
InferShapeContext
;
class
OpDesc
;
template
<
typename
T
>
class
EmptyGradOpMaker
;
}
// namespace framework
namespace
imperative
{
class
OpBase
;
}
// namespace imperative
}
// namespace paddle
namespace
paddle
{
namespace
operators
{
class
AssignValueOp
:
public
framework
::
OperatorWithKernel
{
public:
AssignValueOp
(
const
std
::
string
&
type
,
const
framework
::
VariableNameMap
&
inputs
,
const
framework
::
VariableNameMap
&
outputs
,
const
framework
::
AttributeMap
&
attrs
)
:
OperatorWithKernel
(
type
,
inputs
,
outputs
,
attrs
)
{}
protected:
phi
::
KernelKey
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
return
phi
::
KernelKey
(
framework
::
proto
::
VarType
::
Type
(
ctx
.
Attr
<
int
>
(
"dtype"
)),
ctx
.
GetPlace
());
}
};
class
AssignValueOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
public:
void
Make
()
override
{
AddOutput
(
"Out"
,
"(Tensor) Output tensor of assign_value operator."
);
AddAttr
<
std
::
vector
<
int
>>
(
"shape"
,
"(vector<int>) "
"Shape of values."
);
AddAttr
<
int
>
(
"dtype"
,
"data type of values"
)
.
InEnum
({
framework
::
proto
::
VarType
::
BOOL
,
framework
::
proto
::
VarType
::
INT32
,
framework
::
proto
::
VarType
::
FP32
,
framework
::
proto
::
VarType
::
INT64
});
AddAttr
<
std
::
vector
<
int
>>
(
"bool_values"
,
"store the bool values"
)
.
SetDefault
({});
AddAttr
<
std
::
vector
<
float
>>
(
"fp32_values"
,
"store the float32 values"
)
.
SetDefault
({});
AddAttr
<
std
::
vector
<
int
>>
(
"int32_values"
,
"store the int32 values"
)
.
SetDefault
({});
AddAttr
<
std
::
vector
<
int64_t
>>
(
"int64_values"
,
"store the int64 values"
)
.
SetDefault
({});
AddComment
(
R"DOC(
AssignValue operator
$$Out = values$$
)DOC"
);
}
};
}
// namespace operators
}
// namespace paddle
namespace
ops
=
paddle
::
operators
;
DECLARE_INFER_SHAPE_FUNCTOR
(
assign_value
,
AssignValueInferShapeFunctor
,
PD_INFER_META
(
phi
::
AssignValueInferMeta
));
REGISTER_OPERATOR
(
assign_value
,
ops
::
AssignValueOp
,
ops
::
AssignValueOpMaker
,
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
framework
::
OpDesc
>
,
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
imperative
::
OpBase
>
,
AssignValueInferShapeFunctor
);
paddle/phi/api/yaml/op_compat.yaml
浏览文件 @
d394c9ed
...
...
@@ -153,6 +153,11 @@
get_expected_kernel_type
:
assign
:
GetAssignExpectedKernelType
-
op
:
assign_value
outputs
:
out
:
Out
manual_signature
:
[
assign_value
]
-
op
:
atan
inputs
:
x
:
X
...
...
paddle/phi/api/yaml/static_ops.yaml
浏览文件 @
d394c9ed
...
...
@@ -47,6 +47,17 @@
inplace
:
(x -> out)
backward
:
assign_grad
-
op
:
assign_value
args
:
(int[] shape, DataType dtype, int[] bool_values = {}, float[] fp32_values = {}, int[] int32_values = {}, int64_t[] int64_values = {})
output
:
Tensor(out)
infer_meta
:
func
:
AssignValueInferMeta
param
:
[
shape
,
dtype
]
kernel
:
func
:
assign_value
param
:
[
shape
,
dtype
,
values
]
data_type
:
dtype
-
op
:
broadcast
args
:
(Tensor x, int ring_id = 0, int root = 0)
output
:
Tensor(out)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录