Skip to content

Commit

Permalink
[WIP]: Move k2.Fsa to C++ (#814)
Browse files Browse the repository at this point in the history
* Make k2 ragged tensor more PyTorch-y like.

* Refactoring: Start to add the wrapper class AnyTensor.

* Refactoring.

* initial attempt to support autograd.

* First working version with autograd for Sum().

* Fix comments.

* Support __getitem__ and pickling.

* Add more docs for k2.ragged.Tensor

* Put documentation in header files.

* Minor fixes.

* Fix a typo.

* Fix an error.

* Add more doc.

* Wrap RaggedShape.

* [Not for Merge]: Move k2.Fsa related code to C++.

* Remove extra files.

* Update doc URL. (#821)

* Support manipulating attributes of k2.ragged.Fsa.

* Support indexing 2-axes RaggedTensor, Support slicing for RaggedTensor (#825)

* Support index 2-axes RaggedTensor, Support slicing for RaggedTensor

* Fix compiling errors

* Fix unit test

* Change RaggedTensor.data to RaggedTensor.values

* Fix style

* Add docs

* Run nightly-cpu when pushing code to nightly-cpu branch

* Prune with max_arcs in IntersectDense (#820)

* Add checking for array constructor

* Prune with max arcs

* Minor fix

* Fix typo

* Fix review comments

* Fix typo

* Release v1.8

* Create a ragged tensor from a regular tensor. (#827)

* Create a ragged tensor from a regular tensor.

* Add tests for creating ragged tensors from regular tensors.

* Add more tests.

* Print ragged tensors in a way like what PyTorch is doing.

* Fix test cases.

* Trigger GitHub actions manually. (#829)

* Run GitHub actions on merging. (#830)

* Support printing ragged tensors in a more compact way. (#831)

* Support printing ragged tensors in a more compact way.

* Disable support for torch 1.3.1

* Fix test failures.

* Add levenshtein alignment (#828)

* Add levenshtein graph

* Contruct k2.RaggedTensor in python part

* Fix review comments, return aux_labels in ctc_graph

* Fix tests

* Fix bug of accessing symbols

* Fix bug of accessing symbols

* Change argument name, add levenshtein_distance interface

* Fix test error, add tests for levenshtein_distance

* Fix review comments and add unit test for c++ side

* update the interface of levenshtein alignment

* Fix review comments

* Release v1.9

* Add Fsa.get_forward_scores.

* Implement backprop for Fsa.get_forward_scores()

* Construct RaggedArc from unary function tensor (#30)

* Construct RaggedArc from unary function tensor

* Move fsa_from_unary_ragged and fsa_from_binary_tensor to C++

* add unit test to from unary function; add more functions to fsa

* Remove some rabbish code

* Add more unit tests and docs

* Remove the unused code

* Fix review comments, propagate attributes in To()

* Change the argument type from RaggedAny to Ragged<int32_t> in autograd function

* Delete declaration for template function

* Apply suggestions from code review

Co-authored-by: Fangjun Kuang <[email protected]>

* Fix documentation errors

Co-authored-by: Fangjun Kuang <[email protected]>

Co-authored-by: Wei Kang <[email protected]>
  • Loading branch information
csukuangfj and pkufool authored Sep 30, 2021
1 parent c40adf9 commit 08198a9
Show file tree
Hide file tree
Showing 77 changed files with 4,978 additions and 1,134 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ ignore =
F401,
# W504, line break after binary operator
W504,
# W503, line break before binary operator
W503,
4 changes: 2 additions & 2 deletions .github/workflows/build-cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ on:
branches:
- master
pull_request:
branches:
- master
types: [labeled]

env:
BUILD_TYPE: Release

jobs:
build-cpu:
if: github.event.label.name == 'ready' || github.event_name == 'push'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ on:
push:
branches:
- master
- doc
- doc-test

env:
# debug is faster in terms of compilation time
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ on:
branches:
- master
pull_request:
branches:
- master
types: [labeled]

env:
BUILD_TYPE: Release

jobs:
build:
if: github.event.label.name == 'ready' || github.event_name == 'push'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/nightly-cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
name: nightly-cpu

on:
push:
branches:
- nightly-cpu
schedule:
# minute (0-59)
# hour (0-23)
Expand All @@ -37,13 +40,10 @@ jobs:
matrix:
os: [ubuntu-18.04, macos-10.15]
# Python 3.9 is for PyTorch 1.7.1, 1.8.x, 1.9.0
# torch 1.3.1 supports only Python 3.5/6/7
python-version: [3.6, 3.7, 3.8, 3.9]
torch: ["1.3.1", "1.4.0", "1.5.0", "1.5.1", "1.6.0", "1.7.0", "1.7.1", "1.8.0", "1.8.1", "1.9.0"]
torch: ["1.4.0", "1.5.0", "1.5.1", "1.6.0", "1.7.0", "1.7.1", "1.8.0", "1.8.1", "1.9.0"]
exclude:
- python-version: 3.9 # exclude Python 3.9 for [1.3.1, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0]
torch: "1.3.1"
- python-version: 3.9
- python-version: 3.9 # exclude Python 3.9 for [1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0]
torch: "1.4.0"
- python-version: 3.9
torch: "1.5.0"
Expand All @@ -53,8 +53,6 @@ jobs:
torch: "1.6.0"
- python-version: 3.9
torch: "1.7.0"
- python-version: 3.8 # exclude Python 3.8 for [1.3.1]
torch: "1.3.1"

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests-cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ on:
branches:
- master
pull_request:
branches:
- master
types: [labeled]

jobs:
run-tests-cpu:
if: github.event.label.name == 'ready' || github.event_name == 'push'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ on:
branches:
- master
pull_request:
branches:
- master
types: [labeled]

jobs:
run-tests:
if: github.event.label.name == 'ready' || github.event_name == 'push'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ on:
branches:
- master
pull_request:
branches:
- master
types: [labeled]

env:
BUILD_TYPE: Release

jobs:
build-windows:
# see https://github.com/actions/virtual-environments/blob/win19/20210525.0/images/win/Windows2019-Readme.md
if: github.event.label.name == 'ready' || github.event_name == 'push'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ message(STATUS "Enabled languages: ${languages}")

project(k2 ${languages})

set(K2_VERSION "1.7")
set(K2_VERSION "1.9")

# ----------------- Supported build types for K2 project -----------------
set(ALLOWABLE_BUILD_TYPES Debug Release RelWithDebInfo MinSizeRel)
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<div align="center">
<img src="https://raw.githubusercontent.com/k2-fsa/k2/master/docs/source/_static/logo.png" width=376>
<a href="https://k2-fsa.github.io/k2/">
<img src="https://raw.githubusercontent.com/k2-fsa/k2/master/docs/source/_static/logo.png" width=88>
</a>

[![Documentation Status](https://readthedocs.org/projects/k2/badge/?version=latest)](https://k2.readthedocs.io/en/latest/?badge=latest)
<br/>

[![Documentation Status](https://github.com/k2-fsa/k2/actions/workflows/build-doc.yml/badge.svg)](https://k2-fsa.github.io/k2/)

</div>

Expand Down
197 changes: 0 additions & 197 deletions docs/source/_k2/__init__.py

This file was deleted.

2 changes: 0 additions & 2 deletions docs/source/_k2/ragged/__init__.py

This file was deleted.

5 changes: 0 additions & 5 deletions docs/source/_k2/version/__init__.py

This file was deleted.

3 changes: 1 addition & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
import re
import sys
sys.path.insert(0, os.path.abspath('../../k2/python'))
sys.path.insert(0, os.path.abspath('../../build-ragged/lib'))
sys.path.insert(0, os.path.abspath('../../build/lib'))

import sphinx_rtd_theme

# -- Project information -----------------------------------------------------

project = 'k2'
copyright = '2020, k2 development team'
copyright = '2020-2021, k2 development team'
author = 'k2 development team'


Expand Down
Loading

0 comments on commit 08198a9

Please sign in to comment.