Skip to content

Remove tests requiring genbmm #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from setuptools import setup

with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()

setup(
name="torch_struct",
version="0.5",
Expand All @@ -9,9 +12,12 @@
"torch_struct",
"torch_struct.semirings",
],
long_description=long_description,
package_data={"torch_struct": []},
url="https://github.com/harvardnlp/pytorch_struct",
long_description_content_type="text/markdown",
url="https://github.com/harvardnlp/pytorch-struct",
install_requires=["torch"],
setup_requires=["pytest-runner"],
tests_require=["pytest"],
python_requires='>=3.6',
)
4 changes: 3 additions & 1 deletion torch_struct/semirings/checkpoint.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import torch

has_genbmm = False
try:
import genbmm
from genbmm import BandedMatrix
has_genbmm = True
except ImportError:
pass

Expand Down Expand Up @@ -52,7 +54,7 @@ def backward(ctx, grad_output):
class _CheckpointSemiring(cls):
@staticmethod
def matmul(a, b):
if isinstance(a, genbmm.BandedMatrix):
if has_genbmm and isinstance(a, genbmm.BandedMatrix):
lu = a.lu + b.lu
ld = a.ld + b.ld
c = _CheckBand.apply(a.data, a.lu, a.ld, b.data, b.lu, b.ld)
Expand Down