Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
5c95e5c8
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
5c95e5c8
编写于
9月 06, 2022
作者:
O
OccupyMars2025
提交者:
GitHub
9月 06, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
take some notes about sparse API (#45720)
上级
23def396
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
13 addition
and
13 deletion
+13
-13
paddle/fluid/pybind/eager_functions.cc
paddle/fluid/pybind/eager_functions.cc
+3
-3
paddle/fluid/pybind/eager_utils.cc
paddle/fluid/pybind/eager_utils.cc
+5
-5
paddle/phi/api/include/tensor.h
paddle/phi/api/include/tensor.h
+1
-1
paddle/phi/core/dense_tensor.h
paddle/phi/core/dense_tensor.h
+1
-1
paddle/phi/core/tensor_base.h
paddle/phi/core/tensor_base.h
+3
-3
未找到文件。
paddle/fluid/pybind/eager_functions.cc
浏览文件 @
5c95e5c8
...
...
@@ -523,8 +523,8 @@ static PyObject* eager_api_sparse_coo_tensor(PyObject* self,
std
::
dynamic_pointer_cast
<
phi
::
DenseTensor
>
(
non_zero_indices
.
impl
());
auto
dense_elements
=
std
::
dynamic_pointer_cast
<
phi
::
DenseTensor
>
(
non_zero_elements
.
impl
());
// TODO(zhangkaihuo): After creat
e SparseTensor, call coalesced() to sort and
// merge duplicate indices
// TODO(zhangkaihuo): After creat
ing SparseCooTensor, call coalesced() to sort
//
and
merge duplicate indices
std
::
shared_ptr
<
phi
::
SparseCooTensor
>
coo_tensor
=
std
::
make_shared
<
phi
::
SparseCooTensor
>
(
*
dense_indices
,
*
dense_elements
,
phi
::
make_ddim
(
dense_shape
));
...
...
@@ -537,7 +537,7 @@ static PyObject* eager_api_sparse_coo_tensor(PyObject* self,
autograd_meta
->
SetStopGradient
(
static_cast
<
bool
>
(
stop_gradient
));
if
(
!
autograd_meta
->
GetMutableGradNode
())
{
VLOG
(
3
)
<<
"Tensor("
<<
name
<<
")
have not GradNode, add GradNodeAccumulation for
it."
;
<<
")
doesn't have GradNode, add GradNodeAccumulation to
it."
;
autograd_meta
->
SetGradNode
(
std
::
make_shared
<
egr
::
GradNodeAccumulation
>
(
autograd_meta
));
}
...
...
paddle/fluid/pybind/eager_utils.cc
浏览文件 @
5c95e5c8
...
...
@@ -92,7 +92,7 @@ int TensorDtype2NumpyDtype(phi::DataType dtype) {
}
bool
PyObject_CheckLongOrConvertToLong
(
PyObject
**
obj
)
{
if
(
(
PyLong_Check
(
*
obj
)
&&
!
PyBool_Check
(
*
obj
)
))
{
if
(
PyLong_Check
(
*
obj
)
&&
!
PyBool_Check
(
*
obj
))
{
return
true
;
}
...
...
@@ -129,7 +129,7 @@ bool PyObject_CheckStr(PyObject* obj) { return PyUnicode_Check(obj); }
bool
CastPyArg2AttrBoolean
(
PyObject
*
obj
,
ssize_t
arg_pos
)
{
if
(
obj
==
Py_None
)
{
return
false
;
// To be compatible with QA integration testing. Some
// test case pass in None.
// test case
s
pass in None.
}
else
if
(
obj
==
Py_True
)
{
return
true
;
}
else
if
(
obj
==
Py_False
)
{
...
...
@@ -305,7 +305,7 @@ std::vector<int> CastPyArg2VectorOfInt(PyObject* obj, size_t arg_pos) {
Py_ssize_t
len
=
PyList_Size
(
obj
);
PyObject
*
item
=
nullptr
;
for
(
Py_ssize_t
i
=
0
;
i
<
len
;
i
++
)
{
item
=
PyList_G
etItem
(
obj
,
i
);
item
=
PyList_G
ET_ITEM
(
obj
,
i
);
if
(
PyObject_CheckLongOrConvertToLong
(
&
item
))
{
result
.
emplace_back
(
static_cast
<
int
>
(
PyLong_AsLong
(
item
)));
}
else
{
...
...
@@ -321,13 +321,13 @@ std::vector<int> CastPyArg2VectorOfInt(PyObject* obj, size_t arg_pos) {
Py_ssize_t
len
=
PyTuple_Size
(
obj
);
PyObject
*
item
=
nullptr
;
for
(
Py_ssize_t
i
=
0
;
i
<
len
;
i
++
)
{
item
=
PyTuple_G
etItem
(
obj
,
i
);
item
=
PyTuple_G
ET_ITEM
(
obj
,
i
);
if
(
PyObject_CheckLongOrConvertToLong
(
&
item
))
{
result
.
emplace_back
(
static_cast
<
int
>
(
PyLong_AsLong
(
item
)));
}
else
{
PADDLE_THROW
(
platform
::
errors
::
InvalidArgument
(
"argument (position %d) must be "
"list of
bool
, but got %s at pos %d"
,
"list of
int
, but got %s at pos %d"
,
arg_pos
+
1
,
reinterpret_cast
<
PyTypeObject
*>
(
item
->
ob_type
)
->
tp_name
,
i
));
...
...
paddle/phi/api/include/tensor.h
浏览文件 @
5c95e5c8
...
...
@@ -574,7 +574,7 @@ class PADDLE_API Tensor final {
* unified to Tensor, but Tensor itself is heterogeneous.
*
* Tensor can generally be represented by void* and size_t, place.
* This is suitable for most scenarios including CPU, GPU, HIP,
C
PU, etc.,
* This is suitable for most scenarios including CPU, GPU, HIP,
N
PU, etc.,
* but there are a few cases where this definition cannot be described,
* such as the Tensor representation in third-party lib such as Metal,
* OpenCL, etc., as well as some special Tensor implementations, including
...
...
paddle/phi/core/dense_tensor.h
浏览文件 @
5c95e5c8
...
...
@@ -29,7 +29,7 @@ namespace phi {
class
DenseTensorUtils
;
/// \brief The Dense tensor store values in a contiguous sequential block
/// \brief The Dense tensor store
s
values in a contiguous sequential block
/// of memory where all values are represented. Tensors or multi-dimensional
/// arrays are used in math operators.
/// During the entire life cycle of a DenseTensor, its device type and key
...
...
paddle/phi/core/tensor_base.h
浏览文件 @
5c95e5c8
...
...
@@ -55,12 +55,12 @@ class TensorBase {
virtual
bool
valid
()
const
=
0
;
/// \brief Test whether the storage is allocated.
/// return Whether the storage is allocated.
///
\
return Whether the storage is allocated.
virtual
bool
initialized
()
const
=
0
;
// TODO(Aurelius84): This interface is under intermediate state now.
// We will remove DataType argument in the future. Please DO NOT
// rely on Datatype to
much when design and implement other feature
.
// rely on Datatype to
o much when designing and implementing other features
.
/// \brief Allocate memory with requested size from allocator.
/// \return The mutable data pointer value of type T.
...
...
@@ -70,7 +70,7 @@ class TensorBase {
/// \brief Return the type information of the derived class to support
/// safely downcast in non-rtti environment.
/// return The type information of the derived class.
///
\
return The type information of the derived class.
TypeInfo
<
TensorBase
>
type_info
()
const
{
return
type_info_
;
}
private:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录