Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
马赛克医院
Paddle
提交
3121f889
P
Paddle
项目概览
马赛克医院
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
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,发现更多精彩内容 >>
未验证
提交
3121f889
编写于
11月 03, 2021
作者:
C
Chen Weihang
提交者:
GitHub
11月 03, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change api->include and hapi->api (#36938)
上级
10b039b7
变更
54
隐藏空白更改
内联
并排
Showing
54 changed file
with
343 addition
and
279 deletion
+343
-279
paddle/fluid/framework/operator.h
paddle/fluid/framework/operator.h
+1
-1
paddle/fluid/framework/pten_utils.h
paddle/fluid/framework/pten_utils.h
+2
-2
paddle/fluid/imperative/prepared_operator.h
paddle/fluid/imperative/prepared_operator.h
+1
-1
paddle/fluid/operators/dot_op.h
paddle/fluid/operators/dot_op.h
+3
-3
paddle/fluid/operators/fill_any_like_op.h
paddle/fluid/operators/fill_any_like_op.h
+2
-2
paddle/fluid/operators/matmul_v2_op.h
paddle/fluid/operators/matmul_v2_op.h
+3
-3
paddle/fluid/operators/mean_op.h
paddle/fluid/operators/mean_op.h
+3
-3
paddle/fluid/operators/scale_op.h
paddle/fluid/operators/scale_op.h
+3
-3
paddle/fluid/operators/sign_op.h
paddle/fluid/operators/sign_op.h
+2
-2
paddle/pten/CMakeLists.txt
paddle/pten/CMakeLists.txt
+12
-3
paddle/pten/all.cc
paddle/pten/all.cc
+2
-4
paddle/pten/all.h
paddle/pten/all.h
+7
-6
paddle/pten/api/CMakeLists.txt
paddle/pten/api/CMakeLists.txt
+2
-7
paddle/pten/api/all.cc
paddle/pten/api/all.cc
+3
-1
paddle/pten/api/all.h
paddle/pten/api/all.h
+2
-3
paddle/pten/api/include/backend_set.h
paddle/pten/api/include/backend_set.h
+0
-0
paddle/pten/api/include/creation.h
paddle/pten/api/include/creation.h
+14
-20
paddle/pten/api/include/linalg.h
paddle/pten/api/include/linalg.h
+11
-19
paddle/pten/api/include/manipulation.h
paddle/pten/api/include/manipulation.h
+22
-36
paddle/pten/api/include/math.h
paddle/pten/api/include/math.h
+8
-57
paddle/pten/api/include/tensor.h
paddle/pten/api/include/tensor.h
+0
-0
paddle/pten/api/lib/CMakeLists.txt
paddle/pten/api/lib/CMakeLists.txt
+0
-0
paddle/pten/api/lib/creation.cc
paddle/pten/api/lib/creation.cc
+5
-5
paddle/pten/api/lib/kernel_dispatch.h
paddle/pten/api/lib/kernel_dispatch.h
+2
-2
paddle/pten/api/lib/linalg.cc
paddle/pten/api/lib/linalg.cc
+5
-5
paddle/pten/api/lib/manipulation.cc
paddle/pten/api/lib/manipulation.cc
+4
-4
paddle/pten/api/lib/math.cc
paddle/pten/api/lib/math.cc
+5
-5
paddle/pten/api/lib/utils/CMakeLists.txt
paddle/pten/api/lib/utils/CMakeLists.txt
+0
-0
paddle/pten/api/lib/utils/allocator.cc
paddle/pten/api/lib/utils/allocator.cc
+1
-1
paddle/pten/api/lib/utils/allocator.h
paddle/pten/api/lib/utils/allocator.h
+0
-0
paddle/pten/api/lib/utils/storage.cc
paddle/pten/api/lib/utils/storage.cc
+1
-1
paddle/pten/api/lib/utils/storage.h
paddle/pten/api/lib/utils/storage.h
+0
-0
paddle/pten/api/lib/utils/tensor_utils.cc
paddle/pten/api/lib/utils/tensor_utils.cc
+1
-1
paddle/pten/api/lib/utils/tensor_utils.h
paddle/pten/api/lib/utils/tensor_utils.h
+2
-2
paddle/pten/api/lib/utils/tests/CMakeLists.txt
paddle/pten/api/lib/utils/tests/CMakeLists.txt
+0
-0
paddle/pten/api/lib/utils/tests/test_storage.cc
paddle/pten/api/lib/utils/tests/test_storage.cc
+2
-2
paddle/pten/api/lib/utils/tests/test_tensor_utils.cc
paddle/pten/api/lib/utils/tests/test_tensor_utils.cc
+1
-1
paddle/pten/hapi/CMakeLists.txt
paddle/pten/hapi/CMakeLists.txt
+0
-3
paddle/pten/hapi/include/manipulation.h
paddle/pten/hapi/include/manipulation.h
+0
-25
paddle/pten/hapi/include/math.h
paddle/pten/hapi/include/math.h
+0
-27
paddle/pten/include/core.h
paddle/pten/include/core.h
+0
-0
paddle/pten/include/creation.h
paddle/pten/include/creation.h
+39
-0
paddle/pten/include/infershape.h
paddle/pten/include/infershape.h
+0
-0
paddle/pten/include/linalg.h
paddle/pten/include/linalg.h
+38
-0
paddle/pten/include/manipulation.h
paddle/pten/include/manipulation.h
+39
-0
paddle/pten/include/math.h
paddle/pten/include/math.h
+76
-0
paddle/pten/kernels/cuda/math.cu
paddle/pten/kernels/cuda/math.cu
+1
-1
paddle/pten/tests/test_copy_api.cc
paddle/pten/tests/test_copy_api.cc
+1
-1
paddle/pten/tests/test_dot_api.cc
paddle/pten/tests/test_dot_api.cc
+3
-3
paddle/pten/tests/test_fill_api.cc
paddle/pten/tests/test_fill_api.cc
+3
-3
paddle/pten/tests/test_flatten_api.cc
paddle/pten/tests/test_flatten_api.cc
+3
-3
paddle/pten/tests/test_matmul_api.cc
paddle/pten/tests/test_matmul_api.cc
+2
-2
paddle/pten/tests/test_mean_api.cc
paddle/pten/tests/test_mean_api.cc
+3
-3
paddle/pten/tests/test_scale_api.cc
paddle/pten/tests/test_scale_api.cc
+3
-3
未找到文件。
paddle/fluid/framework/operator.h
浏览文件 @
3121f889
...
@@ -40,7 +40,7 @@ limitations under the License. */
...
@@ -40,7 +40,7 @@ limitations under the License. */
#include "paddle/fluid/platform/variant.h"
#include "paddle/fluid/platform/variant.h"
#include "paddle/utils/flat_hash_map.h"
#include "paddle/utils/flat_hash_map.h"
#include "paddle/pten/
api/
include/core.h"
#include "paddle/pten/include/core.h"
namespace
paddle
{
namespace
paddle
{
namespace
framework
{
namespace
framework
{
...
...
paddle/fluid/framework/pten_utils.h
浏览文件 @
3121f889
...
@@ -25,8 +25,8 @@ limitations under the License. */
...
@@ -25,8 +25,8 @@ limitations under the License. */
#include "paddle/fluid/imperative/type_defs.h"
#include "paddle/fluid/imperative/type_defs.h"
#include "paddle/fluid/platform/macros.h"
#include "paddle/fluid/platform/macros.h"
#include "paddle/fluid/platform/place.h"
#include "paddle/fluid/platform/place.h"
#include "paddle/pten/api/
include/core
.h"
#include "paddle/pten/api/
lib/utils/tensor_utils
.h"
#include "paddle/pten/
hapi/lib/utils/tensor_utils
.h"
#include "paddle/pten/
include/core
.h"
#include "paddle/utils/flat_hash_map.h"
#include "paddle/utils/flat_hash_map.h"
#include "paddle/utils/small_vector.h"
#include "paddle/utils/small_vector.h"
...
...
paddle/fluid/imperative/prepared_operator.h
浏览文件 @
3121f889
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#include "paddle/fluid/imperative/layer.h"
#include "paddle/fluid/imperative/layer.h"
#include "paddle/fluid/imperative/type_defs.h"
#include "paddle/fluid/imperative/type_defs.h"
#include "paddle/pten/
api/
include/core.h"
#include "paddle/pten/include/core.h"
DECLARE_bool
(
use_mkldnn
);
DECLARE_bool
(
use_mkldnn
);
...
...
paddle/fluid/operators/dot_op.h
浏览文件 @
3121f889
...
@@ -20,9 +20,9 @@
...
@@ -20,9 +20,9 @@
#include "paddle/fluid/platform/for_range.h"
#include "paddle/fluid/platform/for_range.h"
// only can include the headers in paddle/pten/api dirs
// only can include the headers in paddle/pten/api dirs
#include "paddle/pten/api/
include/core
.h"
#include "paddle/pten/api/
lib/utils/tensor_utils
.h"
#include "paddle/pten/
api/include/linalg
.h"
#include "paddle/pten/
include/core
.h"
#include "paddle/pten/
hapi/lib/utils/tensor_utils
.h"
#include "paddle/pten/
include/linalg
.h"
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
...
...
paddle/fluid/operators/fill_any_like_op.h
浏览文件 @
3121f889
...
@@ -19,8 +19,8 @@ limitations under the License. */
...
@@ -19,8 +19,8 @@ limitations under the License. */
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/pten_utils.h"
#include "paddle/fluid/framework/pten_utils.h"
#include "paddle/pten/
api/
include/core.h"
#include "paddle/pten/include/core.h"
#include "paddle/pten/
api/
include/creation.h"
#include "paddle/pten/include/creation.h"
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
...
...
paddle/fluid/operators/matmul_v2_op.h
浏览文件 @
3121f889
...
@@ -26,9 +26,9 @@ limitations under the License. */
...
@@ -26,9 +26,9 @@ limitations under the License. */
#include "paddle/fluid/operators/reduce_ops/reduce_sum_op.h"
#include "paddle/fluid/operators/reduce_ops/reduce_sum_op.h"
// only can include the headers in paddle/pten/api dirs
// only can include the headers in paddle/pten/api dirs
#include "paddle/pten/api/
include/core
.h"
#include "paddle/pten/api/
lib/utils/tensor_utils
.h"
#include "paddle/pten/
api/include/linalg
.h"
#include "paddle/pten/
include/core
.h"
#include "paddle/pten/
hapi/lib/utils/tensor_utils
.h"
#include "paddle/pten/
include/linalg
.h"
#if defined(__NVCC__) || defined(__HIPCC__)
#if defined(__NVCC__) || defined(__HIPCC__)
#include "paddle/fluid/operators/reduce_ops/cub_reduce.h"
#include "paddle/fluid/operators/reduce_ops/cub_reduce.h"
...
...
paddle/fluid/operators/mean_op.h
浏览文件 @
3121f889
...
@@ -18,9 +18,9 @@ limitations under the License. */
...
@@ -18,9 +18,9 @@ limitations under the License. */
#include "paddle/fluid/framework/pten_utils.h"
#include "paddle/fluid/framework/pten_utils.h"
// only can include the headers in paddle/top/api dirs
// only can include the headers in paddle/top/api dirs
#include "paddle/pten/api/
include/core
.h"
#include "paddle/pten/api/
lib/utils/tensor_utils
.h"
#include "paddle/pten/
api/include/math
.h"
#include "paddle/pten/
include/core
.h"
#include "paddle/pten/
hapi/lib/utils/tensor_utils
.h"
#include "paddle/pten/
include/math
.h"
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
...
...
paddle/fluid/operators/scale_op.h
浏览文件 @
3121f889
...
@@ -18,9 +18,9 @@ limitations under the License. */
...
@@ -18,9 +18,9 @@ limitations under the License. */
#include "paddle/fluid/framework/pten_utils.h"
#include "paddle/fluid/framework/pten_utils.h"
// only can include the headers in paddle/top/api dirs
// only can include the headers in paddle/top/api dirs
#include "paddle/pten/api/
include/core
.h"
#include "paddle/pten/api/
lib/utils/tensor_utils
.h"
#include "paddle/pten/
api/include/math
.h"
#include "paddle/pten/
include/core
.h"
#include "paddle/pten/
hapi/lib/utils/tensor_utils
.h"
#include "paddle/pten/
include/math
.h"
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
...
...
paddle/fluid/operators/sign_op.h
浏览文件 @
3121f889
...
@@ -20,8 +20,8 @@ limitations under the License. */
...
@@ -20,8 +20,8 @@ limitations under the License. */
#include "paddle/fluid/operators/eigen/eigen_function.h"
#include "paddle/fluid/operators/eigen/eigen_function.h"
// only can include the headers in paddle/pten/api dirs
// only can include the headers in paddle/pten/api dirs
#include "paddle/pten/
api/
include/core.h"
#include "paddle/pten/include/core.h"
#include "paddle/pten/
api/
include/math.h"
#include "paddle/pten/include/math.h"
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
...
...
paddle/pten/CMakeLists.txt
浏览文件 @
3121f889
# pten api
# pten (low level) api headers: include
# pten (high level) api
add_subdirectory
(
api
)
add_subdirectory
(
api
)
# pten high level api
add_subdirectory
(
hapi
)
# pten core components
# pten core components
add_subdirectory
(
core
)
add_subdirectory
(
core
)
# pten kernels for diff device
# pten kernels for diff device
...
@@ -10,3 +9,13 @@ add_subdirectory(kernels)
...
@@ -10,3 +9,13 @@ add_subdirectory(kernels)
add_subdirectory
(
infershape
)
add_subdirectory
(
infershape
)
# pten tests
# pten tests
add_subdirectory
(
tests
)
add_subdirectory
(
tests
)
# make an unity target for compile deps
set
(
PTEN_DEPS convert_utils dense_tensor kernel_factory kernel_context
)
set
(
PTEN_DEPS
${
PTEN_DEPS
}
math_cpu linalg_cpu creation_cpu manipulation_cpu
)
set
(
PTEN_DEPS
${
PTEN_DEPS
}
unary binary
)
if
(
WITH_GPU OR WITH_ROCM
)
set
(
PTEN_DEPS
${
PTEN_DEPS
}
math_cuda linalg_cuda creation_cuda manipulation_cuda
)
endif
()
cc_library
(
pten SRCS all.cc DEPS
${
PTEN_DEPS
}
)
paddle/pten/
hapi/
all.cc
→
paddle/pten/all.cc
浏览文件 @
3121f889
...
@@ -12,8 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,8 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "paddle/pten/
hapi/
all.h"
#include "paddle/pten/all.h"
namespace
paddle
{
namespace
pten
{}
// namespace pten
namespace
experimental
{}
// namespace experimental
}
// namespace paddle
paddle/pten/
hapi/
all.h
→
paddle/pten/all.h
浏览文件 @
3121f889
...
@@ -14,9 +14,10 @@ limitations under the License. */
...
@@ -14,9 +14,10 @@ limitations under the License. */
#pragma once
#pragma once
// user apis
// develop apis
#include "paddle/pten/hapi/include/creation.h"
#include "paddle/pten/include/core.h"
#include "paddle/pten/hapi/include/linalg.h"
#include "paddle/pten/include/creation.h"
#include "paddle/pten/hapi/include/manipulation.h"
#include "paddle/pten/include/infershape.h"
#include "paddle/pten/hapi/include/math.h"
#include "paddle/pten/include/linalg.h"
#include "paddle/pten/hapi/include/tensor.h"
#include "paddle/pten/include/manipulation.h"
#include "paddle/pten/include/math.h"
paddle/pten/api/CMakeLists.txt
浏览文件 @
3121f889
set
(
PTEN_DEPS convert_utils dense_tensor kernel_factory kernel_context
)
add_subdirectory
(
lib
)
set
(
PTEN_DEPS
${
PTEN_DEPS
}
math_cpu linalg_cpu creation_cpu manipulation_cpu
)
set
(
PTEN_DEPS
${
PTEN_DEPS
}
unary binary
)
if
(
WITH_GPU OR WITH_ROCM
)
set
(
PTEN_DEPS
${
PTEN_DEPS
}
math_cuda linalg_cuda creation_cuda manipulation_cuda
)
endif
()
cc_library
(
pten
SRCS all.cc DEPS
${
PTEN_DEPS
}
)
cc_library
(
pten
_hapi SRCS all.cc DEPS linalg_api math_api creation_api
)
paddle/pten/api/all.cc
浏览文件 @
3121f889
...
@@ -14,4 +14,6 @@ limitations under the License. */
...
@@ -14,4 +14,6 @@ limitations under the License. */
#include "paddle/pten/api/all.h"
#include "paddle/pten/api/all.h"
namespace
pten
{}
// namespace pten
namespace
paddle
{
namespace
experimental
{}
// namespace experimental
}
// namespace paddle
paddle/pten/api/all.h
浏览文件 @
3121f889
...
@@ -14,10 +14,9 @@ limitations under the License. */
...
@@ -14,10 +14,9 @@ limitations under the License. */
#pragma once
#pragma once
// develop apis
// user apis
#include "paddle/pten/api/include/core.h"
#include "paddle/pten/api/include/creation.h"
#include "paddle/pten/api/include/creation.h"
#include "paddle/pten/api/include/infershape.h"
#include "paddle/pten/api/include/linalg.h"
#include "paddle/pten/api/include/linalg.h"
#include "paddle/pten/api/include/manipulation.h"
#include "paddle/pten/api/include/manipulation.h"
#include "paddle/pten/api/include/math.h"
#include "paddle/pten/api/include/math.h"
#include "paddle/pten/api/include/tensor.h"
paddle/pten/
h
api/include/backend_set.h
→
paddle/pten/api/include/backend_set.h
浏览文件 @
3121f889
文件已移动
paddle/pten/api/include/creation.h
浏览文件 @
3121f889
...
@@ -14,26 +14,20 @@
...
@@ -14,26 +14,20 @@
#pragma once
#pragma once
#include "paddle/pten/api/include/infershape.h"
#include "paddle/pten/api/include/tensor.h"
#include "paddle/pten/hapi/lib/utils/allocator.h"
#include "paddle/pten/common/data_type.h"
#include "paddle/pten/kernels/cpu/creation.h"
#include "paddle/pten/common/scalar.h"
#include "paddle/pten/kernels/cuda/creation.h"
namespace
pten
{
namespace
paddle
{
namespace
experimental
{
// TODO(YuanRisheng) This function name should be same as User API name.
Tensor
full_like
(
const
Tensor
&
x
,
// TODO(zyfncg) Automatic code generation
const
Scalar
&
value
,
template
<
typename
T
,
typename
ContextT
>
DataType
dtype
=
DataType
::
UNDEFINED
);
DenseTensor
FillAnyLike
(
const
ContextT
&
dev_ctx
,
const
DenseTensor
&
x
,
const
Scalar
&
val
)
{
auto
out_meta
=
UnchangedInferShape
(
x
.
meta
());
const
auto
allocator
=
std
::
make_shared
<
paddle
::
experimental
::
DefaultAllocator
>
(
dev_ctx
.
GetPlace
());
pten
::
DenseTensor
dense_out
(
allocator
,
out_meta
);
FillAnyLike
<
T
>
(
dev_ctx
,
x
,
val
,
&
dense_out
);
return
dense_out
;
}
}
// namespace pten
Tensor
ones_like
(
const
Tensor
&
x
,
DataType
dtype
=
DataType
::
UNDEFINED
);
Tensor
zeros_like
(
const
Tensor
&
x
,
DataType
dtype
=
DataType
::
UNDEFINED
);
}
// namespace experimental
}
// namespace paddle
paddle/pten/api/include/linalg.h
浏览文件 @
3121f889
...
@@ -14,25 +14,17 @@
...
@@ -14,25 +14,17 @@
#pragma once
#pragma once
// See Note: [ How do we organize the kernel directory ]
#include "paddle/pten/api/include/tensor.h"
#include "paddle/pten/api/include/infershape.h"
#include "paddle/pten/hapi/lib/utils/allocator.h"
#include "paddle/pten/kernels/cpu/linalg.h"
#include "paddle/pten/kernels/cuda/linalg.h"
namespace
pten
{
namespace
paddle
{
namespace
experimental
{
template
<
typename
T
,
typename
ContextT
>
Tensor
dot
(
const
Tensor
&
x
,
const
Tensor
&
y
);
DenseTensor
Dot
(
const
ContextT
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
)
{
auto
out_meta
=
DotInferShape
(
x
.
meta
(),
y
.
meta
());
const
auto
allocator
=
std
::
make_shared
<
paddle
::
experimental
::
DefaultAllocator
>
(
dev_ctx
.
GetPlace
());
pten
::
DenseTensor
dense_out
(
allocator
,
out_meta
);
Dot
<
T
>
(
dev_ctx
,
x
,
y
,
&
dense_out
);
return
dense_out
;
}
}
// namespace pten
Tensor
matmul
(
const
Tensor
&
x
,
const
Tensor
&
y
,
bool
transpose_x
,
bool
transpose_y
);
}
// namespace experimental
}
// namespace paddle
paddle/pten/api/include/manipulation.h
浏览文件 @
3121f889
/
/
Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
/
*
Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
//
//
Licensed under the Apache License, Version 2.0 (the "License");
Licensed under the Apache License, Version 2.0 (the "License");
//
you may not use this file except in compliance with the License.
you may not use this file except in compliance with the License.
//
You may obtain a copy of the License at
You may obtain a copy of the License at
//
//
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
//
//
Unless required by applicable law or agreed to in writing, software
Unless required by applicable law or agreed to in writing, software
//
distributed under the License is distributed on an "AS IS" BASIS,
distributed under the License is distributed on an "AS IS" BASIS,
//
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
// limitations under the License.
limitations under the License. */
#pragma once
#pragma once
// See Note: [ How do we organize the kernel directory ]
#include "paddle/pten/api/include/tensor.h"
#include "paddle/pten/api/include/infershape.h"
#include "paddle/pten/hapi/lib/utils/allocator.h"
namespace
paddle
{
#include "paddle/pten/kernels/cpu/manipulation.h"
namespace
experimental
{
#include "paddle/pten/kernels/cuda/manipulation.h"
Tensor
flatten
(
const
Tensor
&
x
,
int
start_axis
,
int
stop_axis
);
namespace
pten
{
}
// namespace experimental
template
<
typename
T
,
typename
ContextT
>
}
// namespace paddle
DenseTensor
Flatten
(
const
ContextT
&
dev_ctx
,
const
DenseTensor
&
x
,
int
start_axis
,
int
stop_axis
)
{
auto
out_meta
=
FlattenInferShape
(
x
.
meta
(),
start_axis
,
stop_axis
);
const
auto
allocator
=
std
::
make_shared
<
paddle
::
experimental
::
DefaultAllocator
>
(
dev_ctx
.
GetPlace
());
pten
::
DenseTensor
dense_out
(
allocator
,
out_meta
);
Flatten
<
T
>
(
dev_ctx
,
x
,
start_axis
,
stop_axis
,
&
dense_out
);
return
dense_out
;
}
}
// namespace pten
paddle/pten/api/include/math.h
浏览文件 @
3121f889
...
@@ -14,63 +14,14 @@ limitations under the License. */
...
@@ -14,63 +14,14 @@ limitations under the License. */
#pragma once
#pragma once
// See Note: [ How do we organize the kernel directory ]
#include "paddle/pten/api/include/tensor.h"
#include "paddle/pten/api/include/infershape.h"
#include "paddle/pten/hapi/lib/utils/allocator.h"
#include "paddle/pten/kernels/cpu/math.h"
#include "paddle/pten/kernels/cuda/math.h"
namespace
pten
{
namespace
paddle
{
namespace
experimental
{
template
<
typename
T
,
typename
ContextT
>
// TODO(chenweihang): add scale API
DenseTensor
Sign
(
const
ContextT
&
dev_ctx
,
const
DenseTensor
&
x
)
{
// TODO(chenweihang): move mean API into stat.h/cc
auto
out_meta
=
UnchangedInferShape
(
x
.
meta
());
Tensor
mean
(
const
Tensor
&
x
);
const
auto
allocator
=
std
::
make_shared
<
paddle
::
experimental
::
DefaultAllocator
>
(
dev_ctx
.
GetPlace
());
pten
::
DenseTensor
dense_out
(
allocator
,
out_meta
);
Sign
<
T
>
(
dev_ctx
,
x
,
&
dense_out
);
return
dense_out
;
}
template
<
typename
T
,
typename
ContextT
>
}
// namespace experimental
DenseTensor
Mean
(
const
ContextT
&
dev_ctx
,
const
DenseTensor
&
x
)
{
}
// namespace paddle
auto
out_meta
=
ReductionInferShape
(
x
.
meta
());
const
auto
allocator
=
std
::
make_shared
<
paddle
::
experimental
::
DefaultAllocator
>
(
dev_ctx
.
GetPlace
());
pten
::
DenseTensor
dense_out
(
allocator
,
out_meta
);
Mean
<
T
>
(
dev_ctx
,
x
,
&
dense_out
);
return
dense_out
;
}
template
<
typename
T
,
typename
ContextT
>
DenseTensor
Scale
(
const
ContextT
&
dev_ctx
,
const
DenseTensor
&
x
,
float
scale
,
float
bias
,
bool
bias_after_scale
)
{
auto
out_meta
=
UnchangedInferShape
(
x
.
meta
());
const
auto
allocator
=
std
::
make_shared
<
paddle
::
experimental
::
DefaultAllocator
>
(
dev_ctx
.
GetPlace
());
pten
::
DenseTensor
dense_out
(
allocator
,
out_meta
);
Scale
<
T
>
(
dev_ctx
,
x
,
scale
,
bias
,
bias_after_scale
,
&
dense_out
);
return
dense_out
;
}
template
<
typename
T
,
typename
ContextT
>
DenseTensor
Scale
(
const
ContextT
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
scale
,
float
bias
,
bool
bias_after_scale
)
{
auto
out_meta
=
UnchangedInferShape
(
x
.
meta
());
const
auto
allocator
=
std
::
make_shared
<
paddle
::
experimental
::
DefaultAllocator
>
(
dev_ctx
.
GetPlace
());
pten
::
DenseTensor
dense_out
(
allocator
,
out_meta
);
ScaleHost
<
T
>
(
dev_ctx
,
x
,
scale
,
bias
,
bias_after_scale
,
&
dense_out
);
return
dense_out
;
}
}
// namespace pten
paddle/pten/
h
api/include/tensor.h
→
paddle/pten/api/include/tensor.h
浏览文件 @
3121f889
文件已移动
paddle/pten/
h
api/lib/CMakeLists.txt
→
paddle/pten/api/lib/CMakeLists.txt
浏览文件 @
3121f889
文件已移动
paddle/pten/
h
api/lib/creation.cc
→
paddle/pten/api/lib/creation.cc
浏览文件 @
3121f889
...
@@ -12,16 +12,16 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,16 +12,16 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "paddle/pten/
h
api/include/creation.h"
#include "paddle/pten/api/include/creation.h"
#include <memory>
#include <memory>
#include "glog/logging.h"
#include "glog/logging.h"
#include "paddle/pten/api/
include/core
.h"
#include "paddle/pten/api/
lib/kernel_dispatch
.h"
#include "paddle/pten/api/
include/infershape
.h"
#include "paddle/pten/api/
lib/utils/allocator
.h"
#include "paddle/pten/
hapi/lib/kernel_dispatch
.h"
#include "paddle/pten/
include/core
.h"
#include "paddle/pten/
hapi/lib/utils/allocator
.h"
#include "paddle/pten/
include/infershape
.h"
namespace
paddle
{
namespace
paddle
{
namespace
experimental
{
namespace
experimental
{
...
...
paddle/pten/
h
api/lib/kernel_dispatch.h
→
paddle/pten/api/lib/kernel_dispatch.h
浏览文件 @
3121f889
...
@@ -18,10 +18,10 @@ limitations under the License. */
...
@@ -18,10 +18,10 @@ limitations under the License. */
#include <string>
#include <string>
#include <utility>
#include <utility>
#include "paddle/pten/api/include/backend_set.h"
#include "paddle/pten/api/include/tensor.h"
#include "paddle/pten/common/data_type.h"
#include "paddle/pten/common/data_type.h"
#include "paddle/pten/common/layout.h"
#include "paddle/pten/common/layout.h"
#include "paddle/pten/hapi/include/backend_set.h"
#include "paddle/pten/hapi/include/tensor.h"
// TODO(chenweihang): split KernelName, Key, Kernel, Factory into diff files
// TODO(chenweihang): split KernelName, Key, Kernel, Factory into diff files
#include "paddle/pten/core/convert_utils.h"
#include "paddle/pten/core/convert_utils.h"
...
...
paddle/pten/
h
api/lib/linalg.cc
→
paddle/pten/api/lib/linalg.cc
浏览文件 @
3121f889
...
@@ -12,19 +12,19 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,19 +12,19 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "paddle/pten/
h
api/include/linalg.h"
#include "paddle/pten/api/include/linalg.h"
#include <memory>
#include <memory>
#include "glog/logging.h"
#include "glog/logging.h"
#include "paddle/pten/api/
include/core
.h"
#include "paddle/pten/api/
lib/kernel_dispatch
.h"
#include "paddle/pten/api/
include/infershape
.h"
#include "paddle/pten/api/
lib/utils/allocator
.h"
#include "paddle/pten/core/convert_utils.h"
#include "paddle/pten/core/convert_utils.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_context.h"
#include "paddle/pten/core/kernel_context.h"
#include "paddle/pten/
hapi/lib/kernel_dispatch
.h"
#include "paddle/pten/
include/core
.h"
#include "paddle/pten/
hapi/lib/utils/allocator
.h"
#include "paddle/pten/
include/infershape
.h"
namespace
paddle
{
namespace
paddle
{
namespace
experimental
{
namespace
experimental
{
...
...
paddle/pten/
h
api/lib/manipulation.cc
→
paddle/pten/api/lib/manipulation.cc
浏览文件 @
3121f889
...
@@ -12,14 +12,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,14 +12,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "paddle/pten/
h
api/include/manipulation.h"
#include "paddle/pten/api/include/manipulation.h"
#include <memory>
#include <memory>
#include "glog/logging.h"
#include "glog/logging.h"
#include "paddle/pten/api/
include/core
.h"
#include "paddle/pten/api/
lib/kernel_dispatch
.h"
#include "paddle/pten/
hapi/lib/kernel_dispatch
.h"
#include "paddle/pten/
api/lib/utils/allocator
.h"
#include "paddle/pten/
hapi/lib/utils/allocator
.h"
#include "paddle/pten/
include/core
.h"
#include "paddle/pten/infershape/unary.h"
#include "paddle/pten/infershape/unary.h"
namespace
paddle
{
namespace
paddle
{
...
...
paddle/pten/
h
api/lib/math.cc
→
paddle/pten/api/lib/math.cc
浏览文件 @
3121f889
...
@@ -12,16 +12,16 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,16 +12,16 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "paddle/pten/
h
api/include/math.h"
#include "paddle/pten/api/include/math.h"
#include <memory>
#include <memory>
#include "glog/logging.h"
#include "glog/logging.h"
#include "paddle/pten/api/
include/core
.h"
#include "paddle/pten/api/
lib/kernel_dispatch
.h"
#include "paddle/pten/api/
include/infershape
.h"
#include "paddle/pten/api/
lib/utils/allocator
.h"
#include "paddle/pten/
hapi/lib/kernel_dispatch
.h"
#include "paddle/pten/
include/core
.h"
#include "paddle/pten/
hapi/lib/utils/allocator
.h"
#include "paddle/pten/
include/infershape
.h"
#include "paddle/pten/infershape/unary.h"
#include "paddle/pten/infershape/unary.h"
namespace
paddle
{
namespace
paddle
{
...
...
paddle/pten/
h
api/lib/utils/CMakeLists.txt
→
paddle/pten/api/lib/utils/CMakeLists.txt
浏览文件 @
3121f889
文件已移动
paddle/pten/
h
api/lib/utils/allocator.cc
→
paddle/pten/api/lib/utils/allocator.cc
浏览文件 @
3121f889
...
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "paddle/pten/
h
api/lib/utils/allocator.h"
#include "paddle/pten/api/lib/utils/allocator.h"
namespace
paddle
{
namespace
paddle
{
namespace
experimental
{
namespace
experimental
{
...
...
paddle/pten/
h
api/lib/utils/allocator.h
→
paddle/pten/api/lib/utils/allocator.h
浏览文件 @
3121f889
文件已移动
paddle/pten/
h
api/lib/utils/storage.cc
→
paddle/pten/api/lib/utils/storage.cc
浏览文件 @
3121f889
...
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "paddle/pten/
h
api/lib/utils/storage.h"
#include "paddle/pten/api/lib/utils/storage.h"
namespace
paddle
{
namespace
paddle
{
namespace
experimental
{
namespace
experimental
{
...
...
paddle/pten/
h
api/lib/utils/storage.h
→
paddle/pten/api/lib/utils/storage.h
浏览文件 @
3121f889
文件已移动
paddle/pten/
h
api/lib/utils/tensor_utils.cc
→
paddle/pten/api/lib/utils/tensor_utils.cc
浏览文件 @
3121f889
...
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "paddle/pten/
h
api/lib/utils/tensor_utils.h"
#include "paddle/pten/api/lib/utils/tensor_utils.h"
namespace
paddle
{
namespace
paddle
{
namespace
experimental
{
namespace
experimental
{
...
...
paddle/pten/
h
api/lib/utils/tensor_utils.h
→
paddle/pten/api/lib/utils/tensor_utils.h
浏览文件 @
3121f889
...
@@ -19,11 +19,11 @@ limitations under the License. */
...
@@ -19,11 +19,11 @@ limitations under the License. */
#include "paddle/fluid/framework/lod_tensor.h"
#include "paddle/fluid/framework/lod_tensor.h"
#include "paddle/fluid/framework/variable.h"
#include "paddle/fluid/framework/variable.h"
#include "paddle/pten/api/lib/utils/allocator.h"
#include "paddle/pten/api/lib/utils/storage.h"
#include "paddle/pten/core/convert_utils.h"
#include "paddle/pten/core/convert_utils.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_factory.h"
#include "paddle/pten/core/kernel_factory.h"
#include "paddle/pten/hapi/lib/utils/allocator.h"
#include "paddle/pten/hapi/lib/utils/storage.h"
namespace
paddle
{
namespace
paddle
{
namespace
experimental
{
namespace
experimental
{
...
...
paddle/pten/
h
api/lib/utils/tests/CMakeLists.txt
→
paddle/pten/api/lib/utils/tests/CMakeLists.txt
浏览文件 @
3121f889
文件已移动
paddle/pten/
h
api/lib/utils/tests/test_storage.cc
→
paddle/pten/api/lib/utils/tests/test_storage.cc
浏览文件 @
3121f889
...
@@ -16,8 +16,8 @@ limitations under the License. */
...
@@ -16,8 +16,8 @@ limitations under the License. */
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include "paddle/pten/
h
api/lib/utils/allocator.h"
#include "paddle/pten/api/lib/utils/allocator.h"
#include "paddle/pten/
h
api/lib/utils/storage.h"
#include "paddle/pten/api/lib/utils/storage.h"
namespace
paddle
{
namespace
paddle
{
namespace
experimental
{
namespace
experimental
{
...
...
paddle/pten/
h
api/lib/utils/tests/test_tensor_utils.cc
→
paddle/pten/api/lib/utils/tests/test_tensor_utils.cc
浏览文件 @
3121f889
...
@@ -14,7 +14,7 @@ limitations under the License. */
...
@@ -14,7 +14,7 @@ limitations under the License. */
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include "paddle/pten/
h
api/lib/utils/tensor_utils.h"
#include "paddle/pten/api/lib/utils/tensor_utils.h"
namespace
paddle
{
namespace
paddle
{
namespace
experimental
{
namespace
experimental
{
...
...
paddle/pten/hapi/CMakeLists.txt
已删除
100644 → 0
浏览文件 @
10b039b7
add_subdirectory
(
lib
)
cc_library
(
pten_hapi SRCS all.cc DEPS linalg_api math_api creation_api
)
paddle/pten/hapi/include/manipulation.h
已删除
100644 → 0
浏览文件 @
10b039b7
/* Copyright (c) 2021 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. */
#pragma once
#include "paddle/pten/hapi/include/tensor.h"
namespace
paddle
{
namespace
experimental
{
Tensor
flatten
(
const
Tensor
&
x
,
int
start_axis
,
int
stop_axis
);
}
// namespace experimental
}
// namespace paddle
paddle/pten/hapi/include/math.h
已删除
100644 → 0
浏览文件 @
10b039b7
/* Copyright (c) 2021 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. */
#pragma once
#include "paddle/pten/hapi/include/tensor.h"
namespace
paddle
{
namespace
experimental
{
// TODO(chenweihang): add scale API
// TODO(chenweihang): move mean API into stat.h/cc
Tensor
mean
(
const
Tensor
&
x
);
}
// namespace experimental
}
// namespace paddle
paddle/pten/
api/
include/core.h
→
paddle/pten/include/core.h
浏览文件 @
3121f889
文件已移动
paddle/pten/
hapi/
include/creation.h
→
paddle/pten/include/creation.h
浏览文件 @
3121f889
...
@@ -14,20 +14,26 @@
...
@@ -14,20 +14,26 @@
#pragma once
#pragma once
#include "paddle/pten/common/data_type.h"
#include "paddle/pten/api/lib/utils/allocator.h"
#include "paddle/pten/common/scalar.h"
#include "paddle/pten/include/infershape.h"
#include "paddle/pten/hapi/include/tensor.h"
#include "paddle/pten/kernels/cpu/creation.h"
#include "paddle/pten/kernels/cuda/creation.h"
namespace
paddle
{
namespace
pten
{
namespace
experimental
{
Tensor
full_like
(
const
Tensor
&
x
,
// TODO(YuanRisheng) This function name should be same as User API name.
const
Scalar
&
value
,
// TODO(zyfncg) Automatic code generation
DataType
dtype
=
DataType
::
UNDEFINED
);
template
<
typename
T
,
typename
ContextT
>
DenseTensor
FillAnyLike
(
const
ContextT
&
dev_ctx
,
const
DenseTensor
&
x
,
const
Scalar
&
val
)
{
auto
out_meta
=
UnchangedInferShape
(
x
.
meta
());
const
auto
allocator
=
std
::
make_shared
<
paddle
::
experimental
::
DefaultAllocator
>
(
dev_ctx
.
GetPlace
());
pten
::
DenseTensor
dense_out
(
allocator
,
out_meta
);
FillAnyLike
<
T
>
(
dev_ctx
,
x
,
val
,
&
dense_out
);
return
dense_out
;
}
Tensor
ones_like
(
const
Tensor
&
x
,
DataType
dtype
=
DataType
::
UNDEFINED
);
}
// namespace pten
Tensor
zeros_like
(
const
Tensor
&
x
,
DataType
dtype
=
DataType
::
UNDEFINED
);
}
// namespace experimental
}
// namespace paddle
paddle/pten/
api/
include/infershape.h
→
paddle/pten/include/infershape.h
浏览文件 @
3121f889
文件已移动
paddle/pten/
hapi/
include/linalg.h
→
paddle/pten/include/linalg.h
浏览文件 @
3121f889
...
@@ -14,17 +14,25 @@
...
@@ -14,17 +14,25 @@
#pragma once
#pragma once
#include "paddle/pten/hapi/include/tensor.h"
// See Note: [ How do we organize the kernel directory ]
#include "paddle/pten/api/lib/utils/allocator.h"
#include "paddle/pten/include/infershape.h"
#include "paddle/pten/kernels/cpu/linalg.h"
#include "paddle/pten/kernels/cuda/linalg.h"
namespace
paddle
{
namespace
pten
{
namespace
experimental
{
Tensor
dot
(
const
Tensor
&
x
,
const
Tensor
&
y
);
template
<
typename
T
,
typename
ContextT
>
DenseTensor
Dot
(
const
ContextT
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
)
{
auto
out_meta
=
DotInferShape
(
x
.
meta
(),
y
.
meta
());
const
auto
allocator
=
std
::
make_shared
<
paddle
::
experimental
::
DefaultAllocator
>
(
dev_ctx
.
GetPlace
());
pten
::
DenseTensor
dense_out
(
allocator
,
out_meta
);
Dot
<
T
>
(
dev_ctx
,
x
,
y
,
&
dense_out
);
return
dense_out
;
}
Tensor
matmul
(
const
Tensor
&
x
,
}
// namespace pten
const
Tensor
&
y
,
bool
transpose_x
,
bool
transpose_y
);
}
// namespace experimental
}
// namespace paddle
paddle/pten/include/manipulation.h
0 → 100644
浏览文件 @
3121f889
// Copyright (c) 2021 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.
#pragma once
// See Note: [ How do we organize the kernel directory ]
#include "paddle/pten/api/lib/utils/allocator.h"
#include "paddle/pten/include/infershape.h"
#include "paddle/pten/kernels/cpu/manipulation.h"
#include "paddle/pten/kernels/cuda/manipulation.h"
namespace
pten
{
template
<
typename
T
,
typename
ContextT
>
DenseTensor
Flatten
(
const
ContextT
&
dev_ctx
,
const
DenseTensor
&
x
,
int
start_axis
,
int
stop_axis
)
{
auto
out_meta
=
FlattenInferShape
(
x
.
meta
(),
start_axis
,
stop_axis
);
const
auto
allocator
=
std
::
make_shared
<
paddle
::
experimental
::
DefaultAllocator
>
(
dev_ctx
.
GetPlace
());
pten
::
DenseTensor
dense_out
(
allocator
,
out_meta
);
Flatten
<
T
>
(
dev_ctx
,
x
,
start_axis
,
stop_axis
,
&
dense_out
);
return
dense_out
;
}
}
// namespace pten
paddle/pten/include/math.h
0 → 100644
浏览文件 @
3121f889
/* Copyright (c) 2021 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. */
#pragma once
// See Note: [ How do we organize the kernel directory ]
#include "paddle/pten/api/lib/utils/allocator.h"
#include "paddle/pten/include/infershape.h"
#include "paddle/pten/kernels/cpu/math.h"
#include "paddle/pten/kernels/cuda/math.h"
namespace
pten
{
template
<
typename
T
,
typename
ContextT
>
DenseTensor
Sign
(
const
ContextT
&
dev_ctx
,
const
DenseTensor
&
x
)
{
auto
out_meta
=
UnchangedInferShape
(
x
.
meta
());
const
auto
allocator
=
std
::
make_shared
<
paddle
::
experimental
::
DefaultAllocator
>
(
dev_ctx
.
GetPlace
());
pten
::
DenseTensor
dense_out
(
allocator
,
out_meta
);
Sign
<
T
>
(
dev_ctx
,
x
,
&
dense_out
);
return
dense_out
;
}
template
<
typename
T
,
typename
ContextT
>
DenseTensor
Mean
(
const
ContextT
&
dev_ctx
,
const
DenseTensor
&
x
)
{
auto
out_meta
=
ReductionInferShape
(
x
.
meta
());
const
auto
allocator
=
std
::
make_shared
<
paddle
::
experimental
::
DefaultAllocator
>
(
dev_ctx
.
GetPlace
());
pten
::
DenseTensor
dense_out
(
allocator
,
out_meta
);
Mean
<
T
>
(
dev_ctx
,
x
,
&
dense_out
);
return
dense_out
;
}
template
<
typename
T
,
typename
ContextT
>
DenseTensor
Scale
(
const
ContextT
&
dev_ctx
,
const
DenseTensor
&
x
,
float
scale
,
float
bias
,
bool
bias_after_scale
)
{
auto
out_meta
=
UnchangedInferShape
(
x
.
meta
());
const
auto
allocator
=
std
::
make_shared
<
paddle
::
experimental
::
DefaultAllocator
>
(
dev_ctx
.
GetPlace
());
pten
::
DenseTensor
dense_out
(
allocator
,
out_meta
);
Scale
<
T
>
(
dev_ctx
,
x
,
scale
,
bias
,
bias_after_scale
,
&
dense_out
);
return
dense_out
;
}
template
<
typename
T
,
typename
ContextT
>
DenseTensor
Scale
(
const
ContextT
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
scale
,
float
bias
,
bool
bias_after_scale
)
{
auto
out_meta
=
UnchangedInferShape
(
x
.
meta
());
const
auto
allocator
=
std
::
make_shared
<
paddle
::
experimental
::
DefaultAllocator
>
(
dev_ctx
.
GetPlace
());
pten
::
DenseTensor
dense_out
(
allocator
,
out_meta
);
ScaleHost
<
T
>
(
dev_ctx
,
x
,
scale
,
bias
,
bias_after_scale
,
&
dense_out
);
return
dense_out
;
}
}
// namespace pten
paddle/pten/kernels/cuda/math.cu
浏览文件 @
3121f889
...
@@ -28,9 +28,9 @@ namespace cub = hipcub;
...
@@ -28,9 +28,9 @@ namespace cub = hipcub;
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/float16.h"
#include "paddle/fluid/platform/float16.h"
#include "paddle/pten/api/lib/utils/tensor_utils.h"
#include "paddle/pten/core/convert_utils.h"
#include "paddle/pten/core/convert_utils.h"
#include "paddle/pten/core/kernel_registry.h"
#include "paddle/pten/core/kernel_registry.h"
#include "paddle/pten/hapi/lib/utils/tensor_utils.h"
namespace
pten
{
namespace
pten
{
...
...
paddle/pten/tests/test_copy_api.cc
浏览文件 @
3121f889
...
@@ -18,8 +18,8 @@ limitations under the License. */
...
@@ -18,8 +18,8 @@ limitations under the License. */
#include "paddle/pten/core/kernel_registry.h"
#include "paddle/pten/core/kernel_registry.h"
#include "paddle/pten/kernels/cpu/utils.h"
#include "paddle/pten/kernels/cpu/utils.h"
#include "paddle/pten/api/lib/utils/allocator.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/hapi/lib/utils/allocator.h"
PT_DECLARE_MODULE
(
UtilsCPU
);
PT_DECLARE_MODULE
(
UtilsCPU
);
...
...
paddle/pten/tests/test_dot_api.cc
浏览文件 @
3121f889
...
@@ -15,13 +15,13 @@ limitations under the License. */
...
@@ -15,13 +15,13 @@ limitations under the License. */
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <memory>
#include <memory>
#include "paddle/pten/
h
api/include/linalg.h"
#include "paddle/pten/api/include/linalg.h"
#include "paddle/pten/api/lib/utils/allocator.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h"
#include "paddle/pten/core/kernel_registry.h"
#include "paddle/pten/hapi/lib/utils/allocator.h"
#include "paddle/pten/
api/
include/linalg.h"
#include "paddle/pten/include/linalg.h"
PT_DECLARE_MODULE
(
LinalgCPU
);
PT_DECLARE_MODULE
(
LinalgCPU
);
...
...
paddle/pten/tests/test_fill_api.cc
浏览文件 @
3121f889
...
@@ -15,13 +15,13 @@ limitations under the License. */
...
@@ -15,13 +15,13 @@ limitations under the License. */
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <memory>
#include <memory>
#include "paddle/pten/
h
api/include/creation.h"
#include "paddle/pten/api/include/creation.h"
#include "paddle/pten/api/lib/utils/allocator.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h"
#include "paddle/pten/core/kernel_registry.h"
#include "paddle/pten/hapi/lib/utils/allocator.h"
#include "paddle/pten/
api/
include/creation.h"
#include "paddle/pten/include/creation.h"
PT_DECLARE_MODULE
(
CreationCPU
);
PT_DECLARE_MODULE
(
CreationCPU
);
...
...
paddle/pten/tests/test_flatten_api.cc
浏览文件 @
3121f889
...
@@ -15,13 +15,13 @@ limitations under the License. */
...
@@ -15,13 +15,13 @@ limitations under the License. */
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <memory>
#include <memory>
#include "paddle/pten/
h
api/include/manipulation.h"
#include "paddle/pten/api/include/manipulation.h"
#include "paddle/pten/api/lib/utils/allocator.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h"
#include "paddle/pten/core/kernel_registry.h"
#include "paddle/pten/hapi/lib/utils/allocator.h"
#include "paddle/pten/
api/
include/manipulation.h"
#include "paddle/pten/include/manipulation.h"
PT_DECLARE_MODULE
(
ManipulationCPU
);
PT_DECLARE_MODULE
(
ManipulationCPU
);
...
...
paddle/pten/tests/test_matmul_api.cc
浏览文件 @
3121f889
...
@@ -15,11 +15,11 @@ limitations under the License. */
...
@@ -15,11 +15,11 @@ limitations under the License. */
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <memory>
#include <memory>
#include "paddle/pten/
h
api/include/linalg.h"
#include "paddle/pten/api/include/linalg.h"
#include "paddle/pten/api/lib/utils/allocator.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h"
#include "paddle/pten/core/kernel_registry.h"
#include "paddle/pten/hapi/lib/utils/allocator.h"
#include "paddle/pten/kernels/cuda/utils.h"
#include "paddle/pten/kernels/cuda/utils.h"
PT_DECLARE_MODULE
(
LinalgCPU
);
PT_DECLARE_MODULE
(
LinalgCPU
);
...
...
paddle/pten/tests/test_mean_api.cc
浏览文件 @
3121f889
...
@@ -15,13 +15,13 @@ limitations under the License. */
...
@@ -15,13 +15,13 @@ limitations under the License. */
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <memory>
#include <memory>
#include "paddle/pten/
h
api/include/math.h"
#include "paddle/pten/api/include/math.h"
#include "paddle/pten/api/lib/utils/allocator.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h"
#include "paddle/pten/core/kernel_registry.h"
#include "paddle/pten/hapi/lib/utils/allocator.h"
#include "paddle/pten/
api/
include/math.h"
#include "paddle/pten/include/math.h"
PT_DECLARE_MODULE
(
MathCPU
);
PT_DECLARE_MODULE
(
MathCPU
);
...
...
paddle/pten/tests/test_scale_api.cc
浏览文件 @
3121f889
...
@@ -15,13 +15,13 @@ limitations under the License. */
...
@@ -15,13 +15,13 @@ limitations under the License. */
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <memory>
#include <memory>
#include "paddle/pten/
h
api/include/math.h"
#include "paddle/pten/api/include/math.h"
#include "paddle/pten/api/lib/utils/allocator.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/core/kernel_registry.h"
#include "paddle/pten/core/kernel_registry.h"
#include "paddle/pten/hapi/lib/utils/allocator.h"
#include "paddle/pten/
api/
include/math.h"
#include "paddle/pten/include/math.h"
PT_DECLARE_MODULE
(
MathCPU
);
PT_DECLARE_MODULE
(
MathCPU
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录