Skip to content
Closed
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
22 changes: 21 additions & 1 deletion bindings/python/flashlight/lib/sequence/criterion.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,33 @@
LICENSE file in the root directory of this source tree.
"""

from .flashlight_lib_sequence_criterion import (
CpuForceAlignmentCriterion,
CpuFullConnectionCriterion,
CpuViterbiPath,
CriterionScaleMode,
)


have_torch = False
try:
import torch

have_torch = True
except ImportError:
pass

if have_torch:
pass
from flashlight.lib.sequence.criterion_torch import (
ASGLoss,
check_tensor,
create_workspace,
FACFunction,
FCCFunction,
get_cuda_stream_as_bytes,
get_data_ptr_as_bytes,
run_backward,
run_direction,
run_forward,
run_get_workspace_size,
)
13 changes: 12 additions & 1 deletion bindings/python/test/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@

class ImportTestCase(unittest.TestCase):
def test_import_lib_sequence(self) -> None:
from flashlight.lib.sequence import criterion
from flashlight.lib.sequence.criterion import (
CpuForceAlignmentCriterion,
CpuFullConnectionCriterion,
CpuViterbiPath,
CriterionScaleMode,
)

if os.getenv("USE_CUDA", "OFF").upper() not in [
"OFF",
Expand All @@ -19,7 +26,11 @@ def test_import_lib_sequence(self) -> None:
"FALSE",
"N",
]:
pass
from flashlight.lib.sequence.flashlight_lib_sequence_criterion import (
CudaForceAlignmentCriterion,
CudaFullConnectionCriterion,
CudaViterbiPath,
)
else:
logging.info("Flashlight Sequence bindings built without CUDA")

Expand Down