From 75bc5d5904c2f6331c5237aa0c6f56c626e77d18 Mon Sep 17 00:00:00 2001 From: yuchen202 <103028470+yuchen202@users.noreply.github.com> Date: Wed, 30 Aug 2023 15:13:40 +0800 Subject: [PATCH 1/6] =?UTF-8?q?8.30=E4=B8=8B=E5=8D=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # doctest: +REQUIRES(env:GPU)这个不清楚怎么改,还请帮忙看一下 --- .../incubate/operators/graph_reindex.py | 66 +++++++++++-------- .../operators/graph_sample_neighbors.py | 26 ++++---- .../incubate/operators/graph_send_recv.py | 57 +++++++++------- .../incubate/operators/softmax_mask_fuse.py | 28 ++++++-- .../softmax_mask_fuse_upper_triangle.py | 31 ++++++--- 5 files changed, 128 insertions(+), 80 deletions(-) diff --git a/python/paddle/incubate/operators/graph_reindex.py b/python/paddle/incubate/operators/graph_reindex.py index 2594ed7ce056ef..cd3b039f79c510 100644 --- a/python/paddle/incubate/operators/graph_reindex.py +++ b/python/paddle/incubate/operators/graph_reindex.py @@ -80,33 +80,45 @@ def graph_reindex( Examples: .. code-block:: python - import paddle - - x = [0, 1, 2] - neighbors_e1 = [8, 9, 0, 4, 7, 6, 7] - count_e1 = [2, 3, 2] - x = paddle.to_tensor(x, dtype="int64") - neighbors_e1 = paddle.to_tensor(neighbors_e1, dtype="int64") - count_e1 = paddle.to_tensor(count_e1, dtype="int32") - - reindex_src, reindex_dst, out_nodes = \ - paddle.incubate.graph_reindex(x, neighbors_e1, count_e1) - # reindex_src: [3, 4, 0, 5, 6, 7, 6] - # reindex_dst: [0, 0, 1, 1, 1, 2, 2] - # out_nodes: [0, 1, 2, 8, 9, 4, 7, 6] - - neighbors_e2 = [0, 2, 3, 5, 1] - count_e2 = [1, 3, 1] - neighbors_e2 = paddle.to_tensor(neighbors_e2, dtype="int64") - count_e2 = paddle.to_tensor(count_e2, dtype="int32") - - neighbors = paddle.concat([neighbors_e1, neighbors_e2]) - count = paddle.concat([count_e1, count_e2]) - reindex_src, reindex_dst, out_nodes = \ - paddle.incubate.graph_reindex(x, neighbors, count) - # reindex_src: [3, 4, 0, 5, 6, 7, 6, 0, 2, 8, 9, 1] - # reindex_dst: [0, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2] - # out_nodes: [0, 1, 2, 8, 9, 4, 7, 6, 3, 5] + >>> import paddle + + >>> x = [0, 1, 2] + >>> neighbors_e1 = [8, 9, 0, 4, 7, 6, 7] + >>> count_e1 = [2, 3, 2] + >>> x = paddle.to_tensor(x, dtype="int64") + >>> neighbors_e1 = paddle.to_tensor(neighbors_e1, dtype="int64") + >>> count_e1 = paddle.to_tensor(count_e1, dtype="int32") + + >>> reindex_src, reindex_dst, out_nodes = \ + ... paddle.incubate.graph_reindex(x, neighbors_e1, count_e1) + >>> print(reindex_src) + Tensor(shape=[7], dtype=int64, place=Place(cpu), stop_gradient=True, + [3, 4, 0, 5, 6, 7, 6]) + >>> print(reindex_dst) + Tensor(shape=[7], dtype=int64, place=Place(cpu), stop_gradient=True, + [0, 0, 1, 1, 1, 2, 2]) + >>> print(out_nodes) + Tensor(shape=[8], dtype=int64, place=Place(cpu), stop_gradient=True, + [0, 1, 2, 8, 9, 4, 7, 6]) + + >>> neighbors_e2 = [0, 2, 3, 5, 1] + >>> count_e2 = [1, 3, 1] + >>> neighbors_e2 = paddle.to_tensor(neighbors_e2, dtype="int64") + >>> count_e2 = paddle.to_tensor(count_e2, dtype="int32") + + >>> neighbors = paddle.concat([neighbors_e1, neighbors_e2]) + >>> count = paddle.concat([count_e1, count_e2]) + >>> reindex_src, reindex_dst, out_nodes = \ + ... paddle.incubate.graph_reindex(x, neighbors, count) + >>> print(reindex_src) + Tensor(shape=[12], dtype=int64, place=Place(cpu), stop_gradient=True, + [3, 4, 0, 5, 6, 7, 6, 0, 2, 8, 9, 1]) + >>> print(reindex_dst) + Tensor(shape=[12], dtype=int64, place=Place(cpu), stop_gradient=True, + [0, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2]) + >>> print(out_nodes) + Tensor(shape=[10], dtype=int64, place=Place(cpu), stop_gradient=True, + [0, 1, 2, 8, 9, 4, 7, 6, 3, 5]) """ if flag_buffer_hashtable: diff --git a/python/paddle/incubate/operators/graph_sample_neighbors.py b/python/paddle/incubate/operators/graph_sample_neighbors.py index 169acca5fdc634..f7db3e266f63ad 100644 --- a/python/paddle/incubate/operators/graph_sample_neighbors.py +++ b/python/paddle/incubate/operators/graph_sample_neighbors.py @@ -80,19 +80,19 @@ def graph_sample_neighbors( Examples: .. code-block:: python - import paddle - # edges: (3, 0), (7, 0), (0, 1), (9, 1), (1, 2), (4, 3), (2, 4), - # (9, 5), (3, 5), (9, 6), (1, 6), (9, 8), (7, 8) - row = [3, 7, 0, 9, 1, 4, 2, 9, 3, 9, 1, 9, 7] - colptr = [0, 2, 4, 5, 6, 7, 9, 11, 11, 13, 13] - nodes = [0, 8, 1, 2] - sample_size = 2 - row = paddle.to_tensor(row, dtype="int64") - colptr = paddle.to_tensor(colptr, dtype="int64") - nodes = paddle.to_tensor(nodes, dtype="int64") - out_neighbors, out_count = \ - paddle.incubate.graph_sample_neighbors(row, colptr, nodes, - sample_size=sample_size) + >>> import paddle + >>> # edges: (3, 0), (7, 0), (0, 1), (9, 1), (1, 2), (4, 3), (2, 4), + >>> # (9, 5), (3, 5), (9, 6), (1, 6), (9, 8), (7, 8) + >>> row = [3, 7, 0, 9, 1, 4, 2, 9, 3, 9, 1, 9, 7] + >>> colptr = [0, 2, 4, 5, 6, 7, 9, 11, 11, 13, 13] + >>> nodes = [0, 8, 1, 2] + >>> sample_size = 2 + >>> row = paddle.to_tensor(row, dtype="int64") + >>> colptr = paddle.to_tensor(colptr, dtype="int64") + >>> nodes = paddle.to_tensor(nodes, dtype="int64") + >>> out_neighbors, out_count = \ + ... paddle.incubate.graph_sample_neighbors(row, colptr, nodes, + ... sample_size=sample_size) """ diff --git a/python/paddle/incubate/operators/graph_send_recv.py b/python/paddle/incubate/operators/graph_send_recv.py index 7a874f19249e15..1d3f11f061a1c7 100644 --- a/python/paddle/incubate/operators/graph_send_recv.py +++ b/python/paddle/incubate/operators/graph_send_recv.py @@ -91,29 +91,40 @@ def graph_send_recv( .. code-block:: python - import paddle - - x = paddle.to_tensor([[0, 2, 3], [1, 4, 5], [2, 6, 7]], dtype="float32") - indexes = paddle.to_tensor([[0, 1], [1, 2], [2, 1], [0, 0]], dtype="int32") - src_index = indexes[:, 0] - dst_index = indexes[:, 1] - out = paddle.incubate.graph_send_recv(x, src_index, dst_index, pool_type="sum") - # Outputs: [[0., 2., 3.], [2., 8., 10.], [1., 4., 5.]] - - x = paddle.to_tensor([[0, 2, 3], [1, 4, 5], [2, 6, 7]], dtype="float32") - indexes = paddle.to_tensor([[0, 1], [2, 1], [0, 0]], dtype="int32") - src_index = indexes[:, 0] - dst_index = indexes[:, 1] - out_size = paddle.max(dst_index) + 1 - out = paddle.incubate.graph_send_recv(x, src_index, dst_index, pool_type="sum", out_size=out_size) - # Outputs: [[0., 2., 3.], [[2., 8., 10.]]] - - x = paddle.to_tensor([[0, 2, 3], [1, 4, 5], [2, 6, 7]], dtype="float32") - indexes = paddle.to_tensor([[0, 1], [2, 1], [0, 0]], dtype="int32") - src_index = indexes[:, 0] - dst_index = indexes[:, 1] - out = paddle.incubate.graph_send_recv(x, src_index, dst_index, pool_type="sum") - # Outputs: [[0., 2., 3.], [2., 8., 10.], [0., 0., 0.]] + >>> import paddle + + >>> x = paddle.to_tensor([[0, 2, 3], [1, 4, 5], [2, 6, 7]], dtype="float32") + >>> indexes = paddle.to_tensor([[0, 1], [1, 2], [2, 1], [0, 0]], dtype="int32") + >>> src_index = indexes[:, 0] + >>> dst_index = indexes[:, 1] + >>> out = paddle.incubate.graph_send_recv(x, src_index, dst_index, pool_type="sum") + >>> print(out) + Tensor(shape=[3, 3], dtype=float32, place=Place(cpu), stop_gradient=True, + [[0. , 2. , 3. ], + [2. , 8. , 10.], + [1. , 4. , 5. ]]) + + >>> x = paddle.to_tensor([[0, 2, 3], [1, 4, 5], [2, 6, 7]], dtype="float32") + >>> indexes = paddle.to_tensor([[0, 1], [2, 1], [0, 0]], dtype="int32") + >>> src_index = indexes[:, 0] + >>> dst_index = indexes[:, 1] + >>> out_size = paddle.max(dst_index) + 1 + >>> out = paddle.incubate.graph_send_recv(x, src_index, dst_index, pool_type="sum", out_size=out_size) + >>> print(out) + Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True, + [[0. , 2. , 3. ], + [2. , 8. , 10.]]) + + >>> x = paddle.to_tensor([[0, 2, 3], [1, 4, 5], [2, 6, 7]], dtype="float32") + >>> indexes = paddle.to_tensor([[0, 1], [2, 1], [0, 0]], dtype="int32") + >>> src_index = indexes[:, 0] + >>> dst_index = indexes[:, 1] + >>> out = paddle.incubate.graph_send_recv(x, src_index, dst_index, pool_type="sum") + >>> print(out) + Tensor(shape=[3, 3], dtype=float32, place=Place(cpu), stop_gradient=True, + [[0. , 2. , 3. ], + [2. , 8. , 10.], + [0. , 0. , 0. ]]) """ diff --git a/python/paddle/incubate/operators/softmax_mask_fuse.py b/python/paddle/incubate/operators/softmax_mask_fuse.py index 178cfd9a046ce7..610b1f332a87d8 100644 --- a/python/paddle/incubate/operators/softmax_mask_fuse.py +++ b/python/paddle/incubate/operators/softmax_mask_fuse.py @@ -45,15 +45,29 @@ def softmax_mask_fuse(x, mask, name=None): Examples: .. code-block:: python - # required: gpu - import paddle - import paddle.incubate as incubate + >>> # doctest: +REQUIRES(env:GPU) + >>> import paddle + >>> import paddle.incubate as incubate - x = paddle.rand([2, 8, 8, 32]) - mask = paddle.rand([2, 1, 8, 32]) + >>> x = paddle.rand([2, 8, 8, 32]) + >>> mask = paddle.rand([2, 1, 8, 32]) - rst = incubate.softmax_mask_fuse(x, mask) - # [[[[0.02404429, 0.04658398, 0.02746007, ..., 0.01489375, 0.02397441, 0.02851614] ... ]]] + >>> rst = incubate.softmax_mask_fuse(x, mask) + >>> print(rst) + >>> Tensor(shape=[1, 1, 32, 32], dtype=float32, place=Place(gpu:0), stop_gradient=True, + >>> [[[[1. , 0. , 0. , ..., 0. , + 0. , 0. ], + [0.49575609, 0.50424391, 0. , ..., 0. , + 0. , 0. ], + [0.26035303, 0.25114325, 0.48850375, ..., 0. , + 0. , 0. ], + ..., + [0.04379999, 0.04194880, 0.05150032, ..., 0.02721255, + 0. , 0. ], + [0.02348574, 0.01959674, 0.02609110, ..., 0.04046615, + 0.02248267, 0. ], + [0.02280738, 0.03144657, 0.02892209, ..., 0.03885521, + 0.03342311, 0.02842640]]]]) """ if in_dynamic_mode(): out = _legacy_C_ops.fused_softmax_mask(x, mask) diff --git a/python/paddle/incubate/operators/softmax_mask_fuse_upper_triangle.py b/python/paddle/incubate/operators/softmax_mask_fuse_upper_triangle.py index dd8e229a1e9c29..34967b28b05d46 100644 --- a/python/paddle/incubate/operators/softmax_mask_fuse_upper_triangle.py +++ b/python/paddle/incubate/operators/softmax_mask_fuse_upper_triangle.py @@ -43,17 +43,28 @@ def softmax_mask_fuse_upper_triangle(x): Examples: .. code-block:: python - # required: gpu - import paddle - import paddle.incubate as incubate + >>> # doctest: +REQUIRES(env:GPU) + >>> import paddle + >>> import paddle.incubate as incubate + >>> paddle.seed(1) + >>> x = paddle.rand((1, 1, 32, 32)) - x = paddle.rand((1, 1, 32, 32)) - - rst = incubate.softmax_mask_fuse_upper_triangle(x) - # [[[[1. , 0. , 0. , ..., 0., 0., 0.], - # [0.45324376, 0.54675621, 0. , ..., 0., 0., 0.], - # [0.32674268, 0.28156221, 0.39169508, ..., 0., 0., 0.] - # ... ]]] + >>> rst = incubate.softmax_mask_fuse_upper_triangle(x) + >>> print(rst) + Tensor(shape=[1, 1, 32, 32], dtype=float32, place=Place(gpu:0), stop_gradient=True, + [[[[1. , 0. , 0. , ..., 0. , + 0. , 0. ], + [0.49575609, 0.50424391, 0. , ..., 0. , + 0. , 0. ], + [0.26035303, 0.25114325, 0.48850375, ..., 0. , + 0. , 0. ], + ..., + [0.04379999, 0.04194880, 0.05150032, ..., 0.02721255, + 0. , 0. ], + [0.02348574, 0.01959674, 0.02609110, ..., 0.04046615, + 0.02248267, 0. ], + [0.02280738, 0.03144657, 0.02892209, ..., 0.03885521, + 0.03342311, 0.02842640]]]]) """ if in_dynamic_mode(): out = _legacy_C_ops.fused_softmax_mask_upper_triangle(x) From 0a05bc9da4d0c5a6ecd914bcb862a4452deec88d Mon Sep 17 00:00:00 2001 From: yuchen202 <103028470+yuchen202@users.noreply.github.com> Date: Fri, 1 Sep 2023 09:39:22 +0800 Subject: [PATCH 2/6] Update softmax_mask_fuse.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改了相关内容 --- .../incubate/operators/softmax_mask_fuse.py | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/python/paddle/incubate/operators/softmax_mask_fuse.py b/python/paddle/incubate/operators/softmax_mask_fuse.py index 610b1f332a87d8..f66abe946f8551 100644 --- a/python/paddle/incubate/operators/softmax_mask_fuse.py +++ b/python/paddle/incubate/operators/softmax_mask_fuse.py @@ -54,20 +54,20 @@ def softmax_mask_fuse(x, mask, name=None): >>> rst = incubate.softmax_mask_fuse(x, mask) >>> print(rst) - >>> Tensor(shape=[1, 1, 32, 32], dtype=float32, place=Place(gpu:0), stop_gradient=True, - >>> [[[[1. , 0. , 0. , ..., 0. , - 0. , 0. ], - [0.49575609, 0.50424391, 0. , ..., 0. , - 0. , 0. ], - [0.26035303, 0.25114325, 0.48850375, ..., 0. , - 0. , 0. ], - ..., - [0.04379999, 0.04194880, 0.05150032, ..., 0.02721255, - 0. , 0. ], - [0.02348574, 0.01959674, 0.02609110, ..., 0.04046615, - 0.02248267, 0. ], - [0.02280738, 0.03144657, 0.02892209, ..., 0.03885521, - 0.03342311, 0.02842640]]]]) + Tensor(shape=[1, 1, 32, 32], dtype=float32, place=Place(gpu:0), stop_gradient=True, + [[[[1. , 0. , 0. , ..., 0. , + 0. , 0. ], + [0.49575609, 0.50424391, 0. , ..., 0. , + 0. , 0. ], + [0.26035303, 0.25114325, 0.48850375, ..., 0. , + 0. , 0. ], + ..., + [0.04379999, 0.04194880, 0.05150032, ..., 0.02721255, + 0. , 0. ], + [0.02348574, 0.01959674, 0.02609110, ..., 0.04046615, + 0.02248267, 0. ], + [0.02280738, 0.03144657, 0.02892209, ..., 0.03885521, + 0.03342311, 0.02842640]]]]) """ if in_dynamic_mode(): out = _legacy_C_ops.fused_softmax_mask(x, mask) From d7d183a1bda1264566936ea69c275f87e1337cba Mon Sep 17 00:00:00 2001 From: yuchen202 <103028470+yuchen202@users.noreply.github.com> Date: Tue, 5 Sep 2023 13:42:22 +0800 Subject: [PATCH 3/6] Update graph_reindex.py --- python/paddle/incubate/operators/graph_reindex.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/paddle/incubate/operators/graph_reindex.py b/python/paddle/incubate/operators/graph_reindex.py index cd3b039f79c510..b0929a2b87b69d 100644 --- a/python/paddle/incubate/operators/graph_reindex.py +++ b/python/paddle/incubate/operators/graph_reindex.py @@ -108,8 +108,7 @@ def graph_reindex( >>> neighbors = paddle.concat([neighbors_e1, neighbors_e2]) >>> count = paddle.concat([count_e1, count_e2]) - >>> reindex_src, reindex_dst, out_nodes = \ - ... paddle.incubate.graph_reindex(x, neighbors, count) + >>> reindex_src, reindex_dst, out_nodes = paddle.incubate.graph_reindex(x, neighbors, count) >>> print(reindex_src) Tensor(shape=[12], dtype=int64, place=Place(cpu), stop_gradient=True, [3, 4, 0, 5, 6, 7, 6, 0, 2, 8, 9, 1]) From 9d0831564ef947565c4d9bb666a247ced186ee15 Mon Sep 17 00:00:00 2001 From: yuchen202 <103028470+yuchen202@users.noreply.github.com> Date: Wed, 6 Sep 2023 10:22:05 +0800 Subject: [PATCH 4/6] Update graph_sample_neighbors.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 全都测了一遍,全都是successful --- python/paddle/incubate/operators/graph_sample_neighbors.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/paddle/incubate/operators/graph_sample_neighbors.py b/python/paddle/incubate/operators/graph_sample_neighbors.py index f7db3e266f63ad..43010e1d6396e9 100644 --- a/python/paddle/incubate/operators/graph_sample_neighbors.py +++ b/python/paddle/incubate/operators/graph_sample_neighbors.py @@ -90,8 +90,7 @@ def graph_sample_neighbors( >>> row = paddle.to_tensor(row, dtype="int64") >>> colptr = paddle.to_tensor(colptr, dtype="int64") >>> nodes = paddle.to_tensor(nodes, dtype="int64") - >>> out_neighbors, out_count = \ - ... paddle.incubate.graph_sample_neighbors(row, colptr, nodes, + >>> out_neighbors, out_count = paddle.incubate.graph_sample_neighbors(row, colptr, nodes, ... sample_size=sample_size) """ From 50fb3c6e260291487b3a4bb740a4a063ad924715 Mon Sep 17 00:00:00 2001 From: SigureMo Date: Thu, 7 Sep 2023 01:38:37 +0800 Subject: [PATCH 5/6] fix cases on cpu --- python/paddle/incubate/operators/graph_reindex.py | 7 +++++-- .../paddle/incubate/operators/graph_sample_neighbors.py | 8 ++++++-- python/paddle/incubate/operators/graph_send_recv.py | 1 - python/paddle/incubate/operators/softmax_mask_fuse.py | 2 +- .../operators/softmax_mask_fuse_upper_triangle.py | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/python/paddle/incubate/operators/graph_reindex.py b/python/paddle/incubate/operators/graph_reindex.py index b0929a2b87b69d..26f55b0fa2ec34 100644 --- a/python/paddle/incubate/operators/graph_reindex.py +++ b/python/paddle/incubate/operators/graph_reindex.py @@ -89,8 +89,11 @@ def graph_reindex( >>> neighbors_e1 = paddle.to_tensor(neighbors_e1, dtype="int64") >>> count_e1 = paddle.to_tensor(count_e1, dtype="int32") - >>> reindex_src, reindex_dst, out_nodes = \ - ... paddle.incubate.graph_reindex(x, neighbors_e1, count_e1) + >>> reindex_src, reindex_dst, out_nodes = paddle.incubate.graph_reindex( + ... x, + ... neighbors_e1, + ... count_e1, + ... ) >>> print(reindex_src) Tensor(shape=[7], dtype=int64, place=Place(cpu), stop_gradient=True, [3, 4, 0, 5, 6, 7, 6]) diff --git a/python/paddle/incubate/operators/graph_sample_neighbors.py b/python/paddle/incubate/operators/graph_sample_neighbors.py index 43010e1d6396e9..66e8d5f2fa5b72 100644 --- a/python/paddle/incubate/operators/graph_sample_neighbors.py +++ b/python/paddle/incubate/operators/graph_sample_neighbors.py @@ -90,8 +90,12 @@ def graph_sample_neighbors( >>> row = paddle.to_tensor(row, dtype="int64") >>> colptr = paddle.to_tensor(colptr, dtype="int64") >>> nodes = paddle.to_tensor(nodes, dtype="int64") - >>> out_neighbors, out_count = paddle.incubate.graph_sample_neighbors(row, colptr, nodes, - ... sample_size=sample_size) + >>> out_neighbors, out_count = paddle.incubate.graph_sample_neighbors( + ... row, + ... colptr, + ... nodes, + ... sample_size=sample_size + ... ) """ diff --git a/python/paddle/incubate/operators/graph_send_recv.py b/python/paddle/incubate/operators/graph_send_recv.py index 1d3f11f061a1c7..84bc656f348a97 100644 --- a/python/paddle/incubate/operators/graph_send_recv.py +++ b/python/paddle/incubate/operators/graph_send_recv.py @@ -125,7 +125,6 @@ def graph_send_recv( [[0. , 2. , 3. ], [2. , 8. , 10.], [0. , 0. , 0. ]]) - """ if pool_type not in ["sum", "mean", "max", "min"]: diff --git a/python/paddle/incubate/operators/softmax_mask_fuse.py b/python/paddle/incubate/operators/softmax_mask_fuse.py index f66abe946f8551..1f2f2c997493d7 100644 --- a/python/paddle/incubate/operators/softmax_mask_fuse.py +++ b/python/paddle/incubate/operators/softmax_mask_fuse.py @@ -40,7 +40,7 @@ def softmax_mask_fuse(x, mask, name=None): For more information, please refer to :ref:`api_guide_Name`. Returns: - 4-D Tensor. A location into which the result is stored. It’s dimension is 4D. Has same shape with x. + 4-D Tensor. A location into which the result is stored. It's dimension is 4D. Has same shape with x. Examples: .. code-block:: python diff --git a/python/paddle/incubate/operators/softmax_mask_fuse_upper_triangle.py b/python/paddle/incubate/operators/softmax_mask_fuse_upper_triangle.py index 34967b28b05d46..d5cf9f7191772f 100644 --- a/python/paddle/incubate/operators/softmax_mask_fuse_upper_triangle.py +++ b/python/paddle/incubate/operators/softmax_mask_fuse_upper_triangle.py @@ -38,7 +38,7 @@ def softmax_mask_fuse_upper_triangle(x): The third dimension of x must be same with the fourth dimension of x. Returns: - 4-D Tensor. A location into which the result is stored. It’s dimension is 4D. Has same dimension with x. + 4-D Tensor. A location into which the result is stored. It's dimension is 4D. Has same dimension with x. Examples: .. code-block:: python From 3b0b3d19307eb572df6429e0ec62e42399bf9b4a Mon Sep 17 00:00:00 2001 From: SigureMo Date: Wed, 6 Sep 2023 18:29:46 +0000 Subject: [PATCH 6/6] fix gpu cases --- .../incubate/operators/softmax_mask_fuse.py | 17 ++--------------- .../softmax_mask_fuse_upper_triangle.py | 2 ++ 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/python/paddle/incubate/operators/softmax_mask_fuse.py b/python/paddle/incubate/operators/softmax_mask_fuse.py index 1f2f2c997493d7..c9a3539ee09e03 100644 --- a/python/paddle/incubate/operators/softmax_mask_fuse.py +++ b/python/paddle/incubate/operators/softmax_mask_fuse.py @@ -53,21 +53,8 @@ def softmax_mask_fuse(x, mask, name=None): >>> mask = paddle.rand([2, 1, 8, 32]) >>> rst = incubate.softmax_mask_fuse(x, mask) - >>> print(rst) - Tensor(shape=[1, 1, 32, 32], dtype=float32, place=Place(gpu:0), stop_gradient=True, - [[[[1. , 0. , 0. , ..., 0. , - 0. , 0. ], - [0.49575609, 0.50424391, 0. , ..., 0. , - 0. , 0. ], - [0.26035303, 0.25114325, 0.48850375, ..., 0. , - 0. , 0. ], - ..., - [0.04379999, 0.04194880, 0.05150032, ..., 0.02721255, - 0. , 0. ], - [0.02348574, 0.01959674, 0.02609110, ..., 0.04046615, - 0.02248267, 0. ], - [0.02280738, 0.03144657, 0.02892209, ..., 0.03885521, - 0.03342311, 0.02842640]]]]) + >>> rst.shape + [2, 8, 8, 32] """ if in_dynamic_mode(): out = _legacy_C_ops.fused_softmax_mask(x, mask) diff --git a/python/paddle/incubate/operators/softmax_mask_fuse_upper_triangle.py b/python/paddle/incubate/operators/softmax_mask_fuse_upper_triangle.py index d5cf9f7191772f..ae02603f27f83c 100644 --- a/python/paddle/incubate/operators/softmax_mask_fuse_upper_triangle.py +++ b/python/paddle/incubate/operators/softmax_mask_fuse_upper_triangle.py @@ -46,7 +46,9 @@ def softmax_mask_fuse_upper_triangle(x): >>> # doctest: +REQUIRES(env:GPU) >>> import paddle >>> import paddle.incubate as incubate + >>> paddle.seed(1) + >>> paddle.set_device("gpu") >>> x = paddle.rand((1, 1, 32, 32)) >>> rst = incubate.softmax_mask_fuse_upper_triangle(x)