forked from DuoLife-QNL/dgl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Sparse] Make functions compatible with PyTorch scalar tensors (dmlc#…
…5163) * use NotImplemented * format * extend to pytorch scalar * reformat * reformat * lint
- Loading branch information
Showing
6 changed files
with
48 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"""Utilities for DGL sparse module.""" | ||
from numbers import Number | ||
from typing import Union | ||
|
||
import torch | ||
|
||
|
||
def is_scalar(x): | ||
"""Check if the input is a scalar.""" | ||
return isinstance(x, Number) or (torch.is_tensor(x) and x.dim() == 0) | ||
|
||
|
||
# Scalar type annotation | ||
Scalar = Union[Number, torch.Tensor] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters