Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
5c1eda19
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看板
未验证
提交
5c1eda19
编写于
3月 06, 2023
作者:
R
Ruibiao Chen
提交者:
GitHub
3月 06, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove InterpretercoreInferShapeContext (#51209)
* Remove InterpretercoreInferShapeContext * Fix lod errors
上级
f1f2a253
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
623 addition
and
1145 deletion
+623
-1145
paddle/fluid/framework/new_executor/interpreter/data_transfer.cc
...fluid/framework/new_executor/interpreter/data_transfer.cc
+1
-1
paddle/fluid/framework/new_executor/interpreter/interpreter_util.cc
...id/framework/new_executor/interpreter/interpreter_util.cc
+1
-2
paddle/fluid/framework/new_executor/new_executor_defs.cc
paddle/fluid/framework/new_executor/new_executor_defs.cc
+4
-523
paddle/fluid/framework/new_executor/new_executor_defs.h
paddle/fluid/framework/new_executor/new_executor_defs.h
+2
-113
paddle/fluid/framework/operator.cc
paddle/fluid/framework/operator.cc
+506
-505
paddle/fluid/framework/operator.h
paddle/fluid/framework/operator.h
+109
-1
未找到文件。
paddle/fluid/framework/new_executor/interpreter/data_transfer.cc
浏览文件 @
5c1eda19
...
...
@@ -129,7 +129,7 @@ void DataTranferHelper::RunAndConstructOpFuncNode(
RuntimeContext
runtime_context
({},
{});
runtime_context
.
inputs
[
"X"
]
=
{
scope_
->
FindVar
(
var_name
)};
runtime_context
.
outputs
[
"Out"
]
=
{
scope_
->
Var
(
new_var_name
)};
Interpretercor
eInferShapeContext
infer_shape_ctx
(
*
op
,
runtime_context
);
Runtim
eInferShapeContext
infer_shape_ctx
(
*
op
,
runtime_context
);
op
.
get
()
->
Info
().
infer_shape_
(
&
infer_shape_ctx
);
// 2. choose kernel
...
...
paddle/fluid/framework/new_executor/interpreter/interpreter_util.cc
浏览文件 @
5c1eda19
...
...
@@ -824,8 +824,7 @@ void BuildOpFuncList(const platform::Place& place,
if
(
!
(
op
->
HasAttr
(
kAllKernelsMustComputeRuntimeShape
)
&&
op
->
Attr
<
bool
>
(
kAllKernelsMustComputeRuntimeShape
)))
{
VLOG
(
4
)
<<
"infer shape"
;
InterpretercoreInferShapeContext
infer_shape_ctx
(
*
op
,
runtime_context
);
RuntimeInferShapeContext
infer_shape_ctx
(
*
op
,
runtime_context
);
// TODO(Aurelius84): In case of control flow ops, they are NOT
// inheritted from OperatorWithKernel.
op_with_kernel
->
Info
().
infer_shape_
(
&
infer_shape_ctx
);
...
...
paddle/fluid/framework/new_executor/new_executor_defs.cc
浏览文件 @
5c1eda19
此差异已折叠。
点击以展开。
paddle/fluid/framework/new_executor/new_executor_defs.h
浏览文件 @
5c1eda19
...
...
@@ -44,115 +44,6 @@ constexpr const char* kH2DStream = "H2DStream";
constexpr
int
kEmptyVarIndex
=
0
;
class
InterpretercoreInferShapeContext
:
public
InferShapeContext
{
public:
InterpretercoreInferShapeContext
(
const
OperatorBase
&
op
,
const
RuntimeContext
&
ctx
);
bool
HasInput
(
const
std
::
string
&
name
)
const
override
;
bool
HasOutput
(
const
std
::
string
&
name
)
const
override
;
bool
HasAttr
(
const
std
::
string
&
name
)
const
override
;
bool
HasInputs
(
const
std
::
string
&
name
)
const
override
;
bool
HasOutputs
(
const
std
::
string
&
name
,
bool
allow_null
=
false
)
const
override
;
AttrReader
Attrs
()
const
override
;
std
::
vector
<
std
::
string
>
Inputs
(
const
std
::
string
&
name
)
const
override
;
std
::
vector
<
std
::
string
>
Outputs
(
const
std
::
string
&
name
)
const
override
;
std
::
string
GetInputNameByIdx
(
size_t
idx
)
const
override
;
std
::
string
GetOutputNameByIdx
(
size_t
idx
)
const
override
;
void
ShareDim
(
const
std
::
string
&
in
,
const
std
::
string
&
out
,
size_t
i
=
0
,
size_t
j
=
0
)
override
;
void
ShareAllLoD
(
const
std
::
string
&
in
,
const
std
::
string
&
out
)
const
override
;
void
ShareLoD
(
const
std
::
string
&
in
,
const
std
::
string
&
out
,
size_t
i
=
0
,
size_t
j
=
0
)
const
override
;
int32_t
GetLoDLevel
(
const
std
::
string
&
in
,
size_t
i
=
0
)
const
override
;
void
SetLoDLevel
(
const
std
::
string
&
out
,
int32_t
lod_level
,
size_t
j
=
0
)
const
override
;
bool
IsRuntime
()
const
override
;
bool
IsRunMKLDNNKernel
()
const
override
;
// TODO(paddle-dev): Can this be template?
paddle
::
small_vector
<
InferShapeVarPtr
,
phi
::
kInputSmallVectorSize
>
GetInputVarPtrs
(
const
std
::
string
&
name
)
const
override
;
paddle
::
small_vector
<
InferShapeVarPtr
,
phi
::
kOutputSmallVectorSize
>
GetOutputVarPtrs
(
const
std
::
string
&
name
)
const
override
;
DDim
GetInputDim
(
const
std
::
string
&
name
)
const
override
;
std
::
vector
<
DDim
>
GetInputsDim
(
const
std
::
string
&
name
)
const
override
;
proto
::
VarType
::
Type
GetInputVarType
(
const
std
::
string
&
name
)
const
override
;
std
::
vector
<
proto
::
VarType
::
Type
>
GetInputsVarType
(
const
std
::
string
&
name
)
const
override
;
std
::
vector
<
proto
::
VarType
::
Type
>
GetOutputsVarType
(
const
std
::
string
&
name
)
const
override
;
void
SetOutputDim
(
const
std
::
string
&
name
,
const
DDim
&
dim
)
override
;
void
SetOutputsDim
(
const
std
::
string
&
name
,
const
std
::
vector
<
DDim
>&
dims
)
override
;
const
phi
::
ArgumentMappingFn
*
GetPhiArgumentMappingFn
()
const
override
;
const
phi
::
KernelSignature
*
GetPhiDefaultKernelSignature
()
const
override
;
void
SetSkipLoD
(
bool
skip
);
protected:
DDim
GetDim
(
Variable
*
var
)
const
;
std
::
vector
<
DDim
>
GetDims
(
const
std
::
vector
<
Variable
*>&
vars
)
const
;
std
::
vector
<
DDim
>
GetRepeatedDims
(
const
std
::
string
&
name
)
const
override
;
void
SetDim
(
Variable
*
var
,
const
DDim
&
dim
);
void
SetDims
(
const
std
::
vector
<
Variable
*>&
vars
,
const
std
::
vector
<
DDim
>&
dims
);
void
SetRepeatedDims
(
const
std
::
string
&
name
,
const
std
::
vector
<
DDim
>&
dims
)
override
;
std
::
vector
<
proto
::
VarType
::
Type
>
GetVarTypes
(
const
std
::
vector
<
Variable
*>&
vars
)
const
;
proto
::
VarType
::
Type
GetVarType
(
Variable
*
var
)
const
;
private:
const
std
::
vector
<
Variable
*>&
InputVars
(
const
std
::
string
&
name
)
const
;
const
std
::
vector
<
Variable
*>&
OutputVars
(
const
std
::
string
&
name
)
const
;
const
OperatorBase
&
op_
;
const
RuntimeContext
&
ctx_
;
bool
can_skip_lod_
;
};
struct
OpKernelFunc
{
OpKernelComputeFunc
compute_func_
;
};
...
...
@@ -260,7 +151,6 @@ enum class OpFuncType {
kGpuSync
,
// GPU or other device kernel without asynchronous operation
kGpuAsync
// GPU or other device kernel with asynchronous operation
};
class
RuntimeInferShapeContext
;
struct
OpFuncNode
{
int
stream_priority_
{
0
};
// lower value, higher priority
...
...
@@ -357,8 +247,7 @@ class Instruction {
std
::
shared_ptr
<
RuntimeContext
>
InnerRuntimeContext
()
const
;
std
::
shared_ptr
<
InterpretercoreInferShapeContext
>
InnerInferShapeContext
()
const
;
std
::
shared_ptr
<
RuntimeInferShapeContext
>
InnerInferShapeContext
()
const
;
std
::
shared_ptr
<
ExecutionContext
>
InnerExecutionContext
()
const
;
...
...
@@ -390,7 +279,7 @@ class Instruction {
const
platform
::
DeviceContext
&
dev_ctx_
;
// not owned
std
::
shared_ptr
<
RuntimeContext
>
runtime_ctx_
;
std
::
shared_ptr
<
Interpretercor
eInferShapeContext
>
infershape_ctx_
;
std
::
shared_ptr
<
Runtim
eInferShapeContext
>
infershape_ctx_
;
std
::
shared_ptr
<
ExecutionContext
>
execution_ctx_
;
std
::
vector
<
size_t
>
gc_check_vars_
;
...
...
paddle/fluid/framework/operator.cc
浏览文件 @
5c1eda19
此差异已折叠。
点击以展开。
paddle/fluid/framework/operator.h
浏览文件 @
5c1eda19
...
...
@@ -34,6 +34,7 @@ limitations under the License. */
#include "paddle/fluid/framework/phi_utils.h"
#include "paddle/fluid/framework/scope.h"
#include "paddle/fluid/framework/selected_rows_utils.h"
#include "paddle/fluid/framework/shape_inference.h"
#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/framework/unused_var_check.h"
#include "paddle/fluid/memory/malloc.h"
...
...
@@ -47,7 +48,6 @@ limitations under the License. */
namespace
paddle
{
namespace
framework
{
class
InferShapeContext
;
class
OpInfo
;
class
Scope
;
class
Variable
;
...
...
@@ -146,6 +146,114 @@ class RuntimeContext {
VariableValueMap
outputs
;
};
class
RuntimeInferShapeContext
:
public
InferShapeContext
{
public:
RuntimeInferShapeContext
(
const
OperatorBase
&
op
,
const
RuntimeContext
&
ctx
);
bool
HasInput
(
const
std
::
string
&
name
)
const
override
;
bool
HasOutput
(
const
std
::
string
&
name
)
const
override
;
bool
HasAttr
(
const
std
::
string
&
name
)
const
override
;
bool
HasInputs
(
const
std
::
string
&
name
)
const
override
;
bool
HasOutputs
(
const
std
::
string
&
name
,
bool
allow_null
=
false
)
const
override
;
AttrReader
Attrs
()
const
override
;
std
::
vector
<
std
::
string
>
Inputs
(
const
std
::
string
&
name
)
const
override
;
std
::
vector
<
std
::
string
>
Outputs
(
const
std
::
string
&
name
)
const
override
;
std
::
string
GetInputNameByIdx
(
size_t
idx
)
const
override
;
std
::
string
GetOutputNameByIdx
(
size_t
idx
)
const
override
;
void
ShareDim
(
const
std
::
string
&
in
,
const
std
::
string
&
out
,
size_t
i
=
0
,
size_t
j
=
0
)
override
;
void
ShareAllLoD
(
const
std
::
string
&
in
,
const
std
::
string
&
out
)
const
override
;
void
ShareLoD
(
const
std
::
string
&
in
,
const
std
::
string
&
out
,
size_t
i
=
0
,
size_t
j
=
0
)
const
override
;
int32_t
GetLoDLevel
(
const
std
::
string
&
in
,
size_t
i
=
0
)
const
override
;
void
SetLoDLevel
(
const
std
::
string
&
out
,
int32_t
lod_level
,
size_t
j
=
0
)
const
override
;
bool
IsRuntime
()
const
override
;
bool
IsRunMKLDNNKernel
()
const
override
;
// TODO(paddle-dev): Can this be template?
paddle
::
small_vector
<
InferShapeVarPtr
,
phi
::
kInputSmallVectorSize
>
GetInputVarPtrs
(
const
std
::
string
&
name
)
const
override
;
paddle
::
small_vector
<
InferShapeVarPtr
,
phi
::
kOutputSmallVectorSize
>
GetOutputVarPtrs
(
const
std
::
string
&
name
)
const
override
;
DDim
GetInputDim
(
const
std
::
string
&
name
)
const
override
;
std
::
vector
<
DDim
>
GetInputsDim
(
const
std
::
string
&
name
)
const
override
;
proto
::
VarType
::
Type
GetInputVarType
(
const
std
::
string
&
name
)
const
override
;
std
::
vector
<
proto
::
VarType
::
Type
>
GetInputsVarType
(
const
std
::
string
&
name
)
const
override
;
std
::
vector
<
proto
::
VarType
::
Type
>
GetOutputsVarType
(
const
std
::
string
&
name
)
const
override
;
void
SetOutputDim
(
const
std
::
string
&
name
,
const
DDim
&
dim
)
override
;
void
SetOutputsDim
(
const
std
::
string
&
name
,
const
std
::
vector
<
DDim
>&
dims
)
override
;
const
phi
::
ArgumentMappingFn
*
GetPhiArgumentMappingFn
()
const
override
;
const
phi
::
KernelSignature
*
GetPhiDefaultKernelSignature
()
const
override
;
void
SetSkipLoD
(
bool
skip
);
protected:
DDim
GetDim
(
Variable
*
var
)
const
;
std
::
vector
<
DDim
>
GetDims
(
const
std
::
vector
<
Variable
*>&
vars
)
const
;
std
::
vector
<
DDim
>
GetRepeatedDims
(
const
std
::
string
&
name
)
const
override
;
void
SetDim
(
Variable
*
var
,
const
DDim
&
dim
);
void
SetDims
(
const
std
::
vector
<
Variable
*>&
vars
,
const
std
::
vector
<
DDim
>&
dims
);
void
SetRepeatedDims
(
const
std
::
string
&
name
,
const
std
::
vector
<
DDim
>&
dims
)
override
;
std
::
vector
<
proto
::
VarType
::
Type
>
GetVarTypes
(
const
std
::
vector
<
Variable
*>&
vars
)
const
;
proto
::
VarType
::
Type
GetVarType
(
Variable
*
var
)
const
;
private:
const
std
::
vector
<
Variable
*>&
InputVars
(
const
std
::
string
&
name
)
const
;
const
std
::
vector
<
Variable
*>&
OutputVars
(
const
std
::
string
&
name
)
const
;
const
OperatorBase
&
op_
;
const
RuntimeContext
&
ctx_
;
bool
can_skip_lod_
{
false
};
};
/**
* OperatorBase has the basic elements that Net will call to do computation.
* Only CreateOperator from OpRegistry will new Operator directly. User
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录