Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
dffe722f
Unverified
Commit
dffe722f
authored
Jan 19, 2023
by
Mufei Li
Committed by
GitHub
Jan 19, 2023
Browse files
Update (#5196)
Co-authored-by:
Ubuntu
<
ubuntu@ip-172-31-36-188.ap-northeast-1.compute.internal
>
parent
995c1913
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
6 deletions
+30
-6
python/dgl/sparse/reduction.py
python/dgl/sparse/reduction.py
+30
-6
No files found.
python/dgl/sparse/reduction.py
View file @
dffe722f
...
...
@@ -35,12 +35,14 @@ def reduce(input: SparseMatrix, dim: Optional[int] = None, rtype: str = "sum"):
Returns
----------
Tensor
torch.
Tensor
Reduced tensor
Examples
----------
Case1: scalar-valued sparse matrix
>>> row = torch.tensor([0, 1, 1])
>>> col = torch.tensor([0, 0, 2])
>>> val = torch.tensor([1, 1, 2])
...
...
@@ -56,6 +58,8 @@ def reduce(input: SparseMatrix, dim: Optional[int] = None, rtype: str = "sum"):
>>> print(dglsp.reduce(A, 1, 'smin'))
tensor([1, 1, 0, 0])
Case2: vector-valued sparse matrix
>>> row = torch.tensor([0, 1, 1])
>>> col = torch.tensor([0, 0, 2])
>>> val = torch.tensor([[1., 2.], [2., 1.], [2., 2.]])
...
...
@@ -99,12 +103,14 @@ def sum(input: SparseMatrix, dim: Optional[int] = None):
Returns
----------
Tensor
torch.
Tensor
Reduced tensor
Examples
----------
Case1: scalar-valued sparse matrix
>>> row = torch.tensor([0, 1, 1])
>>> col = torch.tensor([0, 0, 2])
>>> val = torch.tensor([1, 1, 2])
...
...
@@ -116,6 +122,8 @@ def sum(input: SparseMatrix, dim: Optional[int] = None):
>>> print(dglsp.sum(A, 1))
tensor([1, 3, 0, 0])
Case2: vector-valued sparse matrix
>>> row = torch.tensor([0, 1, 1])
>>> col = torch.tensor([0, 0, 2])
>>> val = torch.tensor([[1, 2], [2, 1], [2, 2]])
...
...
@@ -153,12 +161,14 @@ def smax(input: SparseMatrix, dim: Optional[int] = None):
Returns
----------
Tensor
torch.
Tensor
Reduced tensor
Examples
----------
Case1: scalar-valued sparse matrix
>>> row = torch.tensor([0, 1, 1])
>>> col = torch.tensor([0, 0, 2])
>>> val = torch.tensor([1, 1, 2])
...
...
@@ -170,6 +180,8 @@ def smax(input: SparseMatrix, dim: Optional[int] = None):
>>> print(dglsp.smax(A, 1))
tensor([1, 2, 0, 0])
Case2: vector-valued sparse matrix
>>> row = torch.tensor([0, 1, 1])
>>> col = torch.tensor([0, 0, 2])
>>> val = torch.tensor([[1, 2], [2, 1], [2, 2]])
...
...
@@ -208,12 +220,14 @@ def smin(input: SparseMatrix, dim: Optional[int] = None):
Returns
----------
Tensor
torch.
Tensor
Reduced tensor
Examples
----------
Case1: scalar-valued sparse matrix
>>> row = torch.tensor([0, 1, 1])
>>> col = torch.tensor([0, 0, 2])
>>> val = torch.tensor([1, 1, 2])
...
...
@@ -225,6 +239,8 @@ def smin(input: SparseMatrix, dim: Optional[int] = None):
>>> print(dglsp.smin(A, 1))
tensor([1, 1, 0, 0])
Case2: vector-valued sparse matrix
>>> row = torch.tensor([0, 1, 1])
>>> col = torch.tensor([0, 0, 2])
>>> val = torch.tensor([[1, 2], [2, 1], [2, 2]])
...
...
@@ -267,12 +283,14 @@ def smean(input: SparseMatrix, dim: Optional[int] = None):
Returns
----------
Tensor
torch.
Tensor
Reduced tensor
Examples
----------
Case1: scalar-valued sparse matrix
>>> row = torch.tensor([0, 1, 1])
>>> col = torch.tensor([0, 0, 2])
>>> val = torch.tensor([1., 1., 2.])
...
...
@@ -284,6 +302,8 @@ def smean(input: SparseMatrix, dim: Optional[int] = None):
>>> print(dglsp.smean(A, 1))
tensor([1.0000, 1.5000, 0.0000, 0.0000])
Case2: vector-valued sparse matrix
>>> row = torch.tensor([0, 1, 1])
>>> col = torch.tensor([0, 0, 2])
>>> val = torch.tensor([[1., 2.], [2., 1.], [2., 2.]])
...
...
@@ -326,12 +346,14 @@ def sprod(input: SparseMatrix, dim: Optional[int] = None):
Returns
----------
Tensor
torch.
Tensor
Reduced tensor
Examples
----------
Case1: scalar-valued sparse matrix
>>> row = torch.tensor([0, 1, 1])
>>> col = torch.tensor([0, 0, 2])
>>> val = torch.tensor([1, 1, 2])
...
...
@@ -343,6 +365,8 @@ def sprod(input: SparseMatrix, dim: Optional[int] = None):
>>> print(dglsp.sprod(A, 1))
tensor([1, 2, 0, 0])
Case2: vector-valued sparse matrix
>>> row = torch.tensor([0, 1, 1])
>>> col = torch.tensor([0, 0, 2])
>>> val = torch.tensor([[1, 2], [2, 1], [2, 2]])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment