Skip to content

Commit

Permalink
Fix generating doc. (#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj authored Jun 16, 2021
1 parent dd3da2a commit 565c01b
Show file tree
Hide file tree
Showing 12 changed files with 169 additions and 42 deletions.
7 changes: 0 additions & 7 deletions docs/source/_k2.py → docs/source/_k2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,3 @@ def _create_fsa_vec():

def _is_rand_equivalent():
pass


class version:
build_type = None
git_date = None
git_sha1 = None
__version__ = None
5 changes: 5 additions & 0 deletions docs/source/_k2/version/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build_type = None
git_date = None
git_sha1 = None
__version__ = None
with_cuda = None
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def get_version():
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
exclude_patterns = ['installation/images/*.md']

# -- Options for HTML output -------------------------------------------------

Expand Down
5 changes: 5 additions & 0 deletions docs/source/python_api/dense_fsa.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ __init__

.. automethod:: k2.DenseFsaVec.__init__

duration
~~~~~~~~

.. autoattribute:: k2.DenseFsaVec.duration

_from_dense_fsa_vec
~~~~~~~~~~~~~~~~~~~

Expand Down
25 changes: 25 additions & 0 deletions docs/source/python_api/fsa.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ __init__

.. automethod:: k2.Fsa.__init__

_invalidate_cache_
------------------

.. automethod:: k2.Fsa._invalidate_cache_

to_str
------

.. automethod:: k2.Fsa.to_str

__str__
--------

Expand All @@ -23,6 +33,11 @@ __setattr__

.. automethod:: k2.Fsa.__setattr__

num_arcs
--------

.. autoattribute:: k2.Fsa.num_arcs

labels
------

Expand Down Expand Up @@ -83,6 +98,11 @@ _get_leaving_arc_batches

.. automethod:: k2.Fsa._get_leaving_arc_batches

_get_arc_cdf
------------

.. automethod:: k2.Fsa._get_arc_cdf

_get_forward_scores
-------------------

Expand Down Expand Up @@ -133,6 +153,11 @@ _get_entering_arcs

.. automethod:: k2.Fsa.requires_grad_

rename_tensor_attribute
-----------------------

.. automethod:: k2.Fsa.rename_tensor_attribute

`invert_`
---------

Expand Down
30 changes: 30 additions & 0 deletions docs/source/python_api/fsa_algo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ determinize

.. autofunction:: determinize

expand_ragged_attributes
------------------------

.. autofunction:: expand_ragged_attributes

intersect
---------

Expand All @@ -57,11 +62,36 @@ linear_fsa

.. autofunction:: linear_fsa

linear_fst
----------

.. autofunction:: linear_fst

prune_on_arc_post
-----------------

.. autofunction:: prune_on_arc_post

random_paths
------------

.. autofunction:: random_paths

remove_epsilon
--------------

.. autofunction:: remove_epsilon

remove_epsilon_and_add_self_loops
---------------------------------

.. autofunction:: remove_epsilon_and_add_self_loops

remove_epsilon_self_loops
-------------------------

.. autofunction:: remove_epsilon_self_loops

shortest_path
-------------

Expand Down
31 changes: 23 additions & 8 deletions docs/source/python_api/ops.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ ops

.. currentmodule:: k2

index
-----
index_select
------------

.. autofunction:: index
.. autofunction:: index_select

index_add
---------

.. autofunction:: index_add

index_and_sum
-------------

.. autofunction:: index_and_sum

index_fsa
---------

Expand All @@ -23,12 +28,22 @@ index_ragged

.. autofunction:: index_ragged

index_select
------------

.. autofunction:: index_select

index_tensor
------------

.. autofunction:: index_tensor

index
-----

.. autofunction:: index

cat
---

.. autofunction:: cat

compose_arc_maps
----------------

.. autofunction:: compose_arc_maps
40 changes: 40 additions & 0 deletions docs/source/python_api/ragged_ops.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,43 @@ to_list
-------

.. autofunction:: to_list

sum_per_sublist
---------------

.. autofunction:: sum_per_sublist

cat
---

.. autofunction:: cat

create_ragged2
--------------

.. autofunction:: create_ragged2

get_layer
---------

.. autofunction:: get_layer

unique_sequences
----------------

.. autofunction:: unique_sequences

regular_ragged_shape
--------------------

.. autofunction:: regular_ragged_shape

argmax_per_sublist
------------------

.. autofunction:: argmax_per_sublist

max_per_sublist
---------------

.. autofunction:: max_per_sublist
5 changes: 5 additions & 0 deletions docs/source/python_api/symbol_table.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ merge

.. automethod:: k2.SymbolTable.merge

_check_compatible
-----------------

.. automethod:: k2.SymbolTable._check_compatible

__getitem__
-----------

Expand Down
5 changes: 5 additions & 0 deletions docs/source/python_api/utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ to_str

.. autofunction:: to_str

to_str_simple
-------------

.. autofunction:: to_str_simple

to_tensor
---------

Expand Down
54 changes: 29 additions & 25 deletions k2/python/k2/fsa_algo.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,15 +591,14 @@ def remove_epsilon(fsa: Fsa) -> Fsa:
Args:
fsa:
The input FSA. It can be either a single FSA or an FsaVec.
Works either for CPU or GPU, but the algorithm is different.
We can only use the CPU algorithm if the input is top-sorted,
and the GPU algorithm, while it works for CPU, may not be
very fast.
The input FSA. It can be either a single FSA or an FsaVec.
Works either for CPU or GPU, but the algorithm is different.
We can only use the CPU algorithm if the input is top-sorted,
and the GPU algorithm, while it works for CPU, may not be
very fast.
`fsa` must be free of epsilon loops that have score
greater than 0.
`fsa` must be free of epsilon loops that have score
greater than 0.
Returns:
The resulting Fsa is equivalent to the input `fsa` under the
Expand Down Expand Up @@ -875,23 +874,28 @@ def expand_ragged_attributes(
Supports autograd. If `fsas` had no ragged attributes, returns `fsas`
itself.
Caution: this function will ensure that for final-arcs in the returned
fsa, the corresponding labels for all ragged attributes are -1; it will
add an extra arc at the end is necessary to ensure this, if the
original ragged attributes did not have -1 as their final element on
final-arcs (note: our intention is that -1's on final arcs, like filler
symbols, are removed when making attributes ragged; this is what
fsa_from_unary_function_ragged() does if remove_filler==True (the
default).
fsas: The source Fsa
ret_arc_map: if true, will return a pair (new_fsas, arc_map)
with `arc_map` a tensor of int32 that maps from arcs in the
result to arcs in `fsas`, with -1's for newly created arcs.
If false, just returns new_fsas.
ragged_attribute_names: If specified, just this list of ragged
attributes will be expanded to linear tensor attributes, and
the rest will stay ragged.
Caution:
This function will ensure that for final-arcs in the returned
fsa, the corresponding labels for all ragged attributes are -1; it will
add an extra arc at the end is necessary to ensure this, if the
original ragged attributes did not have -1 as their final element on
final-arcs (note: our intention is that -1's on final arcs, like filler
symbols, are removed when making attributes ragged; this is what
fsa_from_unary_function_ragged() does if remove_filler==True (the
default).
Args:
fsas:
The source Fsa
ret_arc_map:
If true, will return a pair (new_fsas, arc_map)
with `arc_map` a tensor of int32 that maps from arcs in the
result to arcs in `fsas`, with -1's for newly created arcs.
If false, just returns new_fsas.
ragged_attribute_names:
If specified, just this list of ragged
attributes will be expanded to linear tensor attributes, and
the rest will stay ragged.
'''
if ragged_attribute_names is None:
ragged_attribute_tensors = []
Expand Down
2 changes: 1 addition & 1 deletion k2/python/k2/ragged/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def max_per_sublist(src: Union[_k2.RaggedFloat, _k2.RaggedInt],
initial_value: float = torch.finfo(torch.float32).min
) -> torch.Tensor: # noqa
'''Compute the max per sublist for a ragged tensor (including
`initial_value` in the maximum)
`initial_value` in the maximum)
The max is computed on the last layer, ignoring other layers, so it's
as if you removed other layers first.
Expand Down

0 comments on commit 565c01b

Please sign in to comment.