k2 icon indicating copy to clipboard operation
k2 copied to clipboard

Combining individual Fsas to FsaVec

Open danpovey opened this issue 5 years ago • 8 comments

This is to support https://github.com/k2-fsa/snowfall/pull/35 @csukuangfj perhaps you have time to do this? It's probably more urgent than the pinned allocator stuff.

danpovey avatar Dec 08 '20 03:12 danpovey

.. I am thinking we could perhaps call it stack(), since that's what it's really doing.(?) But of course this will cause a name clash with the same thing for ragged once we expose that. I wonder whether we should have separate namespaces, k2.fsa vs k2.ragged.

danpovey avatar Dec 08 '20 03:12 danpovey

I think k2.create_fsa_vec already supports it.

csukuangfj avatar Dec 08 '20 03:12 csukuangfj

Ah OK. There is something I'm not totally satisfied about here but not sure how to solve it.

Firstly, its documentation says: "Create an FsaVec from a list of FSAs "... Firstly, FsaVec is a notion from C++ that we haven't explained here. But also the documentation doesn't say whether the input must have 2 or 3 axes (presumably 2), and this notion isn't explained at the python level. I guess we don't have to explain it now, but I guess it will get confusing... There is a kind of conflict between the name Fsa at the Python level and Fsa at the C++ level. Again, not sure how to solve this. I always want documentation to be unambiguous in its meaning, so it's a shame that one word means 2 things. We can maybe consider changes in naming or structure to make this easier to explain in future.

danpovey avatar Dec 08 '20 03:12 danpovey

BTW what do the axes mean in the Fsa object? I always observe shapes like: [156234, None] - is the first the number of states, and the second an indication that each state might have a variable number of arcs?

pzelasko avatar Dec 08 '20 04:12 pzelasko

@pzelasko

BTW what do the axes mean in the Fsa object?

Please refer to the documentation: https://github.com/k2-fsa/k2/blob/66da100fc013cbd9a4d7f6ffaf6de3601c6e9ee8/k2/python/k2/fsa.py#L771-L777

csukuangfj avatar Dec 08 '20 04:12 csukuangfj

I saw that, but I don't think it explains the meaning of the last "None" anywhere?

pzelasko avatar Dec 08 '20 04:12 pzelasko

I saw that, but I don't think it explains the meaning of the last "None" anywhere?

The following note may be relevant:

https://github.com/k2-fsa/k2/blob/66da100fc013cbd9a4d7f6ffaf6de3601c6e9ee8/docs/array.txt#L29-L37

The Nones are for dimensions where the shape is not known because it is variable.

csukuangfj avatar Dec 08 '20 05:12 csukuangfj

We definitely need to improve the documentation.

csukuangfj avatar Dec 08 '20 05:12 csukuangfj