Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore strides CHECK in FromTorch when input tensor is empty #782

Merged
merged 4 commits into from
Jul 22, 2021

Conversation

pkufool
Copy link
Collaborator

@pkufool pkufool commented Jul 14, 2021

@csukuangfj
Copy link
Collaborator

@glynpu
Could you try this pull request and see if it solves the issue in
k2-fsa/snowfall#227 (comment)

@pkufool
Copy link
Collaborator Author

pkufool commented Jul 22, 2021

I think this PR do solve the issue (k2-fsa/snowfall#227 (comment)), apart from the stride checking problem, there is also a bug in Transpose that return "null" index_values when the input is empty FsaVec (with no fsa at all).
Actually, there are two kinds of Array1 with Dim() equals to zero, one is constructed from default constructor (region_ == nullptr), the other is constructed from Array1(ContextPtr c, int32_t size) with size equals to zero. And, many of the functions can not handle the first one as input, because we would call GetContext() at beginning which causes crash. Do we need a CHECK at these functions or return directly when the input Array1 with a nullptr region.

@pkufool
Copy link
Collaborator Author

pkufool commented Jul 22, 2021

I want to add a test case to cover the empty FsaVec, but I didn't find a way to construct a empty FsaVec.

I thought there are some kinds of FsaVec, the first, FsaVec without any fsa (this kind cause this crash), the second, FsaVec contains empty fsas without states, the third, FsaVec contains empty fsas with states(surely no arcs).

@danpovey
Copy link
Collaborator

I think this PR do solve the issue (k2-fsa/snowfall#227 (comment)), apart from the stride checking problem, there is also a bug in Transpose that return "null" index_values when the input is empty FsaVec (with no fsa at all).
Actually, there are two kinds of Array1 with Dim() equals to zero, one is constructed from default constructor (region_ == nullptr), the other is constructed from Array1(ContextPtr c, int32_t size) with size equals to zero. And, many of the functions can not handle the first one as input, because we would call GetContext() at beginning which causes crash. Do we need a CHECK at these functions or return directly when the input Array1 with a nullptr region.

An Array1 that's default-constructed, with no region, is considered invalid. That is, it should not appear as an input argument to functions, and should not be produced as output from a function that had valid inputs. It can be considered an error, or just lead to a crash, if passed into a function.

@danpovey
Copy link
Collaborator

@pkufool feel free to merge if you think this is ready.

@csukuangfj
Copy link
Collaborator

@danpovey Could you give @pkufool merge permissions for this repo? I guess he does not have merge permissions.

@danpovey danpovey merged commit fc57541 into k2-fsa:master Jul 22, 2021
@pkufool pkufool deleted the fix_crash branch July 24, 2021 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants