Skip to content

Commit 08198a9

Browse files
csukuangfjpkufool
andauthored
[WIP]: Move k2.Fsa to C++ (#814)
* 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 <csukuangfj@gmail.com> * Fix documentation errors Co-authored-by: Fangjun Kuang <csukuangfj@gmail.com> Co-authored-by: Wei Kang <wkang@pku.org.cn>
1 parent c40adf9 commit 08198a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+4978
-1134
lines changed

.flake8

+2
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ ignore =
1818
F401,
1919
# W504, line break after binary operator
2020
W504,
21+
# W503, line break before binary operator
22+
W503,

.github/workflows/build-cpu.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ on:
2323
branches:
2424
- master
2525
pull_request:
26-
branches:
27-
- master
26+
types: [labeled]
2827

2928
env:
3029
BUILD_TYPE: Release
3130

3231
jobs:
3332
build-cpu:
33+
if: github.event.label.name == 'ready' || github.event_name == 'push'
3434
runs-on: ${{ matrix.os }}
3535
strategy:
3636
fail-fast: false

.github/workflows/build-doc.yml

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ on:
2222
push:
2323
branches:
2424
- master
25+
- doc
26+
- doc-test
2527

2628
env:
2729
# debug is faster in terms of compilation time

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ on:
2323
branches:
2424
- master
2525
pull_request:
26-
branches:
27-
- master
26+
types: [labeled]
2827

2928
env:
3029
BUILD_TYPE: Release
3130

3231
jobs:
3332
build:
33+
if: github.event.label.name == 'ready' || github.event_name == 'push'
3434
runs-on: ${{ matrix.os }}
3535
strategy:
3636
fail-fast: false

.github/workflows/nightly-cpu.yml

+5-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
name: nightly-cpu
1818

1919
on:
20+
push:
21+
branches:
22+
- nightly-cpu
2023
schedule:
2124
# minute (0-59)
2225
# hour (0-23)
@@ -37,13 +40,10 @@ jobs:
3740
matrix:
3841
os: [ubuntu-18.04, macos-10.15]
3942
# Python 3.9 is for PyTorch 1.7.1, 1.8.x, 1.9.0
40-
# torch 1.3.1 supports only Python 3.5/6/7
4143
python-version: [3.6, 3.7, 3.8, 3.9]
42-
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"]
44+
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"]
4345
exclude:
44-
- 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]
45-
torch: "1.3.1"
46-
- python-version: 3.9
46+
- python-version: 3.9 # exclude Python 3.9 for [1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0]
4747
torch: "1.4.0"
4848
- python-version: 3.9
4949
torch: "1.5.0"
@@ -53,8 +53,6 @@ jobs:
5353
torch: "1.6.0"
5454
- python-version: 3.9
5555
torch: "1.7.0"
56-
- python-version: 3.8 # exclude Python 3.8 for [1.3.1]
57-
torch: "1.3.1"
5856

5957
steps:
6058
- uses: actions/checkout@v2

.github/workflows/run-tests-cpu.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ on:
2323
branches:
2424
- master
2525
pull_request:
26-
branches:
27-
- master
26+
types: [labeled]
2827

2928
jobs:
3029
run-tests-cpu:
30+
if: github.event.label.name == 'ready' || github.event_name == 'push'
3131
runs-on: ${{ matrix.os }}
3232
strategy:
3333
fail-fast: false

.github/workflows/run-tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ on:
2323
branches:
2424
- master
2525
pull_request:
26-
branches:
27-
- master
26+
types: [labeled]
2827

2928
jobs:
3029
run-tests:
30+
if: github.event.label.name == 'ready' || github.event_name == 'push'
3131
runs-on: ${{ matrix.os }}
3232
strategy:
3333
fail-fast: false

.github/workflows/windows.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ on:
2222
branches:
2323
- master
2424
pull_request:
25-
branches:
26-
- master
25+
types: [labeled]
2726

2827
env:
2928
BUILD_TYPE: Release
3029

3130
jobs:
3231
build-windows:
3332
# see https://github.com/actions/virtual-environments/blob/win19/20210525.0/images/win/Windows2019-Readme.md
33+
if: github.event.label.name == 'ready' || github.event_name == 'push'
3434
runs-on: ${{ matrix.os }}
3535
strategy:
3636
fail-fast: false

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ message(STATUS "Enabled languages: ${languages}")
4242

4343
project(k2 ${languages})
4444

45-
set(K2_VERSION "1.7")
45+
set(K2_VERSION "1.9")
4646

4747
# ----------------- Supported build types for K2 project -----------------
4848
set(ALLOWABLE_BUILD_TYPES Debug Release RelWithDebInfo MinSizeRel)

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<div align="center">
2-
<img src="https://raw.githubusercontent.com/k2-fsa/k2/master/docs/source/_static/logo.png" width=376>
2+
<a href="https://k2-fsa.github.io/k2/">
3+
<img src="https://raw.githubusercontent.com/k2-fsa/k2/master/docs/source/_static/logo.png" width=88>
4+
</a>
35

4-
[![Documentation Status](https://readthedocs.org/projects/k2/badge/?version=latest)](https://k2.readthedocs.io/en/latest/?badge=latest)
6+
<br/>
7+
8+
[![Documentation Status](https://github.com/k2-fsa/k2/actions/workflows/build-doc.yml/badge.svg)](https://k2-fsa.github.io/k2/)
59

610
</div>
711

docs/source/_k2/__init__.py

-197
This file was deleted.

docs/source/_k2/ragged/__init__.py

-2
This file was deleted.

docs/source/_k2/version/__init__.py

-5
This file was deleted.

docs/source/conf.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414
import re
1515
import sys
1616
sys.path.insert(0, os.path.abspath('../../k2/python'))
17-
sys.path.insert(0, os.path.abspath('../../build-ragged/lib'))
1817
sys.path.insert(0, os.path.abspath('../../build/lib'))
1918

2019
import sphinx_rtd_theme
2120

2221
# -- Project information -----------------------------------------------------
2322

2423
project = 'k2'
25-
copyright = '2020, k2 development team'
24+
copyright = '2020-2021, k2 development team'
2625
author = 'k2 development team'
2726

2827

0 commit comments

Comments
 (0)