Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
61a933ac
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看板
未验证
提交
61a933ac
编写于
2月 14, 2023
作者:
H
HongyuJia
提交者:
GitHub
2月 14, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Polish Namespace] Polish operants namespace (#50420)
* polish namespace * change static_tensor_operants * polish namespace
上级
78eb2d87
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
48 addition
and
50 deletion
+48
-50
paddle/fluid/framework/custom_operator.cc
paddle/fluid/framework/custom_operator.cc
+3
-4
paddle/fluid/prim/tests/init_env_utils.cc
paddle/fluid/prim/tests/init_env_utils.cc
+5
-5
paddle/fluid/prim/tests/test_static_prim.cc
paddle/fluid/prim/tests/test_static_prim.cc
+7
-7
paddle/fluid/prim/utils/eager/eager_tensor_operants.cc
paddle/fluid/prim/utils/eager/eager_tensor_operants.cc
+2
-2
paddle/fluid/prim/utils/eager/eager_tensor_operants.h
paddle/fluid/prim/utils/eager/eager_tensor_operants.h
+6
-3
paddle/fluid/prim/utils/static/static_tensor_operants.cc
paddle/fluid/prim/utils/static/static_tensor_operants.cc
+2
-2
paddle/fluid/prim/utils/static/static_tensor_operants.h
paddle/fluid/prim/utils/static/static_tensor_operants.h
+6
-3
paddle/fluid/pybind/eager_functions.cc
paddle/fluid/pybind/eager_functions.cc
+7
-8
paddle/phi/api/include/operants_base.h
paddle/phi/api/include/operants_base.h
+0
-0
paddle/phi/api/include/operants_manager.h
paddle/phi/api/include/operants_manager.h
+2
-4
paddle/phi/api/include/tensor_operants.h
paddle/phi/api/include/tensor_operants.h
+1
-1
paddle/phi/api/lib/CMakeLists.txt
paddle/phi/api/lib/CMakeLists.txt
+4
-0
paddle/phi/api/lib/operants_manager.cc
paddle/phi/api/lib/operants_manager.cc
+1
-4
paddle/phi/api/lib/tensor.cc
paddle/phi/api/lib/tensor.cc
+2
-2
paddle/phi/core/CMakeLists.txt
paddle/phi/core/CMakeLists.txt
+0
-5
未找到文件。
paddle/fluid/framework/custom_operator.cc
浏览文件 @
61a933ac
...
...
@@ -46,8 +46,8 @@ limitations under the License. */
#endif
#include "gflags/gflags.h"
#include "paddle/phi/api/include/operants_manager.h"
#include "paddle/phi/api/include/tensor_operants.h"
#include "paddle/phi/core/operants_manager.h"
DECLARE_string
(
tensor_operants_mode
);
...
...
@@ -278,9 +278,8 @@ static void RunKernelFunc(const framework::ExecutionContext& ctx,
VLOG
(
3
)
<<
"Custom Operator: Run ComputeFunc."
;
FLAGS_tensor_operants_mode
=
"phi"
;
if
(
paddle
::
operants
::
OperantsManager
::
Instance
().
phi_operants
.
get
()
==
nullptr
)
{
paddle
::
operants
::
OperantsManager
::
Instance
().
phi_operants
.
reset
(
if
(
paddle
::
OperantsManager
::
Instance
().
phi_operants
.
get
()
==
nullptr
)
{
paddle
::
OperantsManager
::
Instance
().
phi_operants
.
reset
(
new
paddle
::
operants
::
PhiTensorOperants
());
VLOG
(
4
)
<<
"Initialize phi tensor operants successfully"
;
}
...
...
paddle/fluid/prim/tests/init_env_utils.cc
浏览文件 @
61a933ac
...
...
@@ -15,16 +15,16 @@
#include "paddle/fluid/prim/tests/init_env_utils.h"
#include "paddle/fluid/prim/utils/eager/eager_tensor_operants.h"
#include "paddle/fluid/prim/utils/static/static_tensor_operants.h"
#include "paddle/phi/
cor
e/operants_manager.h"
#include "paddle/phi/
api/includ
e/operants_manager.h"
namespace
paddle
{
namespace
prim
{
void
InitTensorOperants
()
{
paddle
::
operants
::
OperantsManager
::
Instance
().
eager_operants
.
reset
(
new
paddle
::
operants
::
EagerTensorOperants
());
paddle
::
operants
::
OperantsManager
::
Instance
().
static_operants
.
reset
(
new
paddle
::
operants
::
StaticTensorOperants
());
paddle
::
OperantsManager
::
Instance
().
eager_operants
.
reset
(
new
paddle
::
prim
::
EagerTensorOperants
());
paddle
::
OperantsManager
::
Instance
().
static_operants
.
reset
(
new
paddle
::
prim
::
StaticTensorOperants
());
}
}
// namespace prim
...
...
paddle/fluid/prim/tests/test_static_prim.cc
浏览文件 @
61a933ac
...
...
@@ -23,9 +23,9 @@
#include "paddle/fluid/prim/utils/static/desc_tensor.h"
#include "paddle/fluid/prim/utils/static/static_tensor_operants.h"
#include "paddle/fluid/prim/utils/utils.h"
#include "paddle/phi/api/include/operants_manager.h"
#include "paddle/phi/core/enforce.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/core/operants_manager.h"
DECLARE_bool
(
prim_enabled
);
DECLARE_string
(
tensor_operants_mode
);
...
...
@@ -148,8 +148,8 @@ class TestCompositeGradMaker : public CompositeGradOpMakerBase {
TEST
(
StaticPrim
,
TanhBackwardComposite
)
{
// Initialized environment
FLAGS_tensor_operants_mode
=
"static"
;
paddle
::
operants
::
OperantsManager
::
Instance
().
static_operants
.
reset
(
new
paddle
::
operants
::
StaticTensorOperants
());
paddle
::
OperantsManager
::
Instance
().
static_operants
.
reset
(
new
paddle
::
prim
::
StaticTensorOperants
());
TestBaseProgram
base_program
=
TestBaseProgram
();
auto
*
target_block
=
base_program
.
GetBlock
(
0
);
...
...
@@ -234,8 +234,8 @@ TEST(StaticPrim, TanhBackwardComposite) {
TEST
(
StaticCompositeGradMaker
,
TestMutiInputMethod
)
{
// Initialized environment
FLAGS_tensor_operants_mode
=
"static"
;
paddle
::
operants
::
OperantsManager
::
Instance
().
static_operants
.
reset
(
new
paddle
::
operants
::
StaticTensorOperants
());
paddle
::
OperantsManager
::
Instance
().
static_operants
.
reset
(
new
paddle
::
prim
::
StaticTensorOperants
());
TestBaseProgram
base_program
=
TestBaseProgram
();
auto
*
target_block
=
base_program
.
GetBlock
(
0
);
...
...
@@ -301,8 +301,8 @@ TEST(StaticCompositeGradMaker, TestMutiInputMethod) {
TEST
(
StaticCompositeGradMaker
,
TestMutiOutputMethod
)
{
// Initialized environment
FLAGS_tensor_operants_mode
=
"static"
;
paddle
::
operants
::
OperantsManager
::
Instance
().
static_operants
.
reset
(
new
paddle
::
operants
::
StaticTensorOperants
());
paddle
::
OperantsManager
::
Instance
().
static_operants
.
reset
(
new
paddle
::
prim
::
StaticTensorOperants
());
TestBaseProgram
base_program
=
TestBaseProgram
();
auto
*
target_block
=
base_program
.
GetBlock
(
0
);
...
...
paddle/fluid/prim/utils/eager/eager_tensor_operants.cc
浏览文件 @
61a933ac
...
...
@@ -19,11 +19,11 @@
namespace
paddle
{
namespace
operants
{
namespace
prim
{
Tensor
EagerTensorOperants
::
multiply
(
const
Tensor
&
x
,
const
Tensor
&
y
)
{
return
::
multiply_ad_func
(
x
,
y
);
}
}
// namespace
operants
}
// namespace
prim
}
// namespace paddle
paddle/fluid/prim/utils/eager/eager_tensor_operants.h
浏览文件 @
61a933ac
...
...
@@ -14,13 +14,16 @@
#pragma once
#include "paddle/phi/api/include/operants_base.h"
#include "paddle/phi/api/include/tensor.h"
#include "paddle/phi/core/macros.h"
#include "paddle/phi/core/operants_base.h"
namespace
paddle
{
namespace
operants
{
namespace
prim
{
using
Tensor
=
paddle
::
experimental
::
Tensor
;
using
TensorOperantsBase
=
paddle
::
operants
::
TensorOperantsBase
;
class
EagerTensorOperants
:
public
TensorOperantsBase
{
public:
...
...
@@ -32,5 +35,5 @@ class EagerTensorOperants : public TensorOperantsBase {
DISABLE_COPY_AND_ASSIGN
(
EagerTensorOperants
);
};
}
// namespace
operants
}
// namespace
prim
}
// namespace paddle
paddle/fluid/prim/utils/static/static_tensor_operants.cc
浏览文件 @
61a933ac
...
...
@@ -20,12 +20,12 @@
namespace
paddle
{
namespace
operants
{
namespace
prim
{
using
DescTensor
=
paddle
::
prim
::
DescTensor
;
Tensor
StaticTensorOperants
::
multiply
(
const
Tensor
&
x
,
const
Tensor
&
y
)
{
return
paddle
::
prim
::
multiply
<
DescTensor
>
(
x
,
y
);
}
}
// namespace
operants
}
// namespace
prim
}
// namespace paddle
paddle/fluid/prim/utils/static/static_tensor_operants.h
浏览文件 @
61a933ac
...
...
@@ -14,13 +14,16 @@
#pragma once
#include "paddle/phi/api/include/operants_base.h"
#include "paddle/phi/api/include/tensor.h"
#include "paddle/phi/core/macros.h"
#include "paddle/phi/core/operants_base.h"
namespace
paddle
{
namespace
operants
{
namespace
prim
{
using
Tensor
=
paddle
::
experimental
::
Tensor
;
using
TensorOperantsBase
=
paddle
::
operants
::
TensorOperantsBase
;
class
StaticTensorOperants
:
public
TensorOperantsBase
{
public:
...
...
@@ -32,5 +35,5 @@ class StaticTensorOperants : public TensorOperantsBase {
DISABLE_COPY_AND_ASSIGN
(
StaticTensorOperants
);
};
}
// namespace
operants
}
// namespace
prim
}
// namespace paddle
paddle/fluid/pybind/eager_functions.cc
浏览文件 @
61a933ac
...
...
@@ -61,8 +61,8 @@ typedef SSIZE_T ssize_t;
#endif
#include "gflags/gflags.h"
#include "paddle/phi/api/include/operants_manager.h"
#include "paddle/phi/api/include/tensor_operants.h"
#include "paddle/phi/core/operants_manager.h"
DECLARE_string
(
tensor_operants_mode
);
...
...
@@ -503,10 +503,10 @@ static PyObject* eager_api_init_eager_and_static_tensor_operants(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
EAGER_TRY
paddle
::
operants
::
OperantsManager
::
Instance
().
eager_operants
.
reset
(
new
paddle
::
operants
::
EagerTensorOperants
());
paddle
::
operants
::
OperantsManager
::
Instance
().
static_operants
.
reset
(
new
paddle
::
operants
::
StaticTensorOperants
());
paddle
::
OperantsManager
::
Instance
().
eager_operants
.
reset
(
new
paddle
::
prim
::
EagerTensorOperants
());
paddle
::
OperantsManager
::
Instance
().
static_operants
.
reset
(
new
paddle
::
prim
::
StaticTensorOperants
());
VLOG
(
4
)
<<
"Initialize eager and static tensor operants successfully"
;
RETURN_PY_NONE
...
...
@@ -518,9 +518,8 @@ static PyObject* eager_api_run_custom_op(PyObject* self,
PyObject
*
kwargs
)
{
EAGER_TRY
FLAGS_tensor_operants_mode
=
"phi"
;
if
(
paddle
::
operants
::
OperantsManager
::
Instance
().
phi_operants
.
get
()
==
nullptr
)
{
paddle
::
operants
::
OperantsManager
::
Instance
().
phi_operants
.
reset
(
if
(
paddle
::
OperantsManager
::
Instance
().
phi_operants
.
get
()
==
nullptr
)
{
paddle
::
OperantsManager
::
Instance
().
phi_operants
.
reset
(
new
paddle
::
operants
::
PhiTensorOperants
());
VLOG
(
4
)
<<
"Initialize phi tensor operants successfully"
;
}
...
...
paddle/phi/
cor
e/operants_base.h
→
paddle/phi/
api/includ
e/operants_base.h
浏览文件 @
61a933ac
文件已移动
paddle/phi/
cor
e/operants_manager.h
→
paddle/phi/
api/includ
e/operants_manager.h
浏览文件 @
61a933ac
...
...
@@ -14,15 +14,14 @@
#pragma once
#include "paddle/phi/api/include/operants_base.h"
#include "paddle/phi/api/include/tensor.h"
#include "paddle/phi/core/macros.h"
#include "paddle/phi/core/operants_base.h"
namespace
paddle
{
namespace
operants
{
using
Tensor
=
paddle
::
experimental
::
Tensor
;
using
TensorOperantsBase
=
paddle
::
operants
::
TensorOperantsBase
;
/**
* [ Why need OperantsManager? ]
...
...
@@ -73,5 +72,4 @@ class OperantsManager {
DISABLE_COPY_AND_ASSIGN
(
OperantsManager
);
};
}
// namespace operants
}
// namespace paddle
paddle/phi/api/include/tensor_operants.h
浏览文件 @
61a933ac
...
...
@@ -14,9 +14,9 @@
#pragma once
#include "paddle/phi/api/include/operants_base.h"
#include "paddle/phi/api/include/tensor.h"
#include "paddle/phi/core/macros.h"
#include "paddle/phi/core/operants_base.h"
namespace
paddle
{
...
...
paddle/phi/api/lib/CMakeLists.txt
浏览文件 @
61a933ac
...
...
@@ -316,3 +316,7 @@ cc_library(
phi_tensor_operants
SRCS tensor_operants.cc
DEPS phi_function_api
)
cc_library
(
operants_manager
SRCS operants_manager.cc
DEPS flags
)
paddle/phi/
core
/operants_manager.cc
→
paddle/phi/
api/lib
/operants_manager.cc
浏览文件 @
61a933ac
...
...
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/phi/
cor
e/operants_manager.h"
#include "paddle/phi/
api/includ
e/operants_manager.h"
#include "gflags/gflags.h"
#include "glog/logging.h"
...
...
@@ -23,8 +23,6 @@ DECLARE_string(tensor_operants_mode);
namespace
paddle
{
namespace
operants
{
OperantsManager
&
OperantsManager
::
Instance
()
{
static
OperantsManager
g_op_manager
;
return
g_op_manager
;
...
...
@@ -63,5 +61,4 @@ Tensor OperantsManager::multiply(const Tensor& x, const Tensor& y) {
}
}
}
// namespace operants
}
// namespace paddle
paddle/phi/api/lib/tensor.cc
浏览文件 @
61a933ac
...
...
@@ -21,13 +21,13 @@ limitations under the License. */
#include "glog/logging.h"
#include "paddle/phi/api/include/context_pool.h"
#include "paddle/phi/api/include/operants_manager.h"
#include "paddle/phi/api/lib/utils/allocator.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/backends/gpu/gpu_info.h"
#include "paddle/phi/core/ddim.h"
#include "paddle/phi/core/dense_tensor.h"
#include "paddle/phi/core/enforce.h"
#include "paddle/phi/core/operants_manager.h"
#include "paddle/phi/core/selected_rows.h"
#include "paddle/phi/core/sparse_coo_tensor.h"
#include "paddle/phi/core/sparse_csr_tensor.h"
...
...
@@ -435,7 +435,7 @@ void Tensor::reset_inplace_version(bool set_to_zero) {
}
PADDLE_API
Tensor
operator
*
(
const
Tensor
&
x
,
const
Tensor
&
y
)
{
return
paddle
::
operants
::
OperantsManager
::
Instance
().
multiply
(
x
,
y
);
return
paddle
::
OperantsManager
::
Instance
().
multiply
(
x
,
y
);
}
}
// namespace experimental
...
...
paddle/phi/core/CMakeLists.txt
浏览文件 @
61a933ac
...
...
@@ -114,11 +114,6 @@ cc_library(
SRCS custom_kernel.cc
DEPS kernel_factory
)
cc_library
(
operants_manager
SRCS operants_manager.cc
DEPS phi_enforce
)
cc_library
(
mixed_vector
SRCS mixed_vector.cc
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录