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

[Cherry-pick 2.0.1] Fix virtual function issue with CTC decoder (#3230) #3238

Merged
merged 1 commit into from
Apr 5, 2023

Conversation

mthrok
Copy link
Collaborator

@mthrok mthrok commented Apr 4, 2023

Summary:
Currently, creating CTCDecoder object by passing a language model to lm argument without assigning it to a variable elsewhere causes RuntimeError: Tried to call pure virtual function "LM::start".

According to discussions on PyBind11, (
pybind/pybind11#4013 and pybind/pybind11#2839
) this is due to Python object garbage-collected by the time it's used by code implemented in C++. It attempts to call methods defined in Python, which overrides the base pure virtual function, but the object which provides this override gets deleted by garbage collrector, as the original object is not reference counted.

This commit fixes this by simply assiging the given lm object as an attribute of CTCDecoder class.

Address #3218

Pull Request resolved: #3230

Reviewed By: hwangjeff

Differential Revision: D44642989

Pulled By: mthrok

fbshipit-source-id: a90af828c7c576bc0eb505164327365ebaadc471

Summary:
Currently, creating CTCDecoder object by passing a language model to
`lm` argument without assigning it to a variable elsewhere causes
`RuntimeError: Tried to call pure virtual function "LM::start"`.

According to discussions on PyBind11, (
pybind/pybind11#4013 and
pybind/pybind11#2839
) this is due to Python object garbage-collected by the time
it's used by code implemented in C++. It attempts to call
methods defined in Python, which overrides the base pure virtual
function, but the object which provides this override gets
deleted by garbage collrector, as the original object is not
reference counted.

This commit fixes this by simply assiging the given `lm` object
as an attribute of CTCDecoder class.

Address #3218

Pull Request resolved: #3230

Reviewed By: hwangjeff

Differential Revision: D44642989

Pulled By: mthrok

fbshipit-source-id: a90af828c7c576bc0eb505164327365ebaadc471
@mthrok mthrok mentioned this pull request Apr 4, 2023
@mthrok mthrok changed the title Fix virtual function issue with CTC decoder (#3230) [Cherry-pick 2.0.1] Fix virtual function issue with CTC decoder (#3230) Apr 4, 2023
@mthrok mthrok merged commit a4ea69e into release/2.0 Apr 5, 2023
@mthrok mthrok deleted the cherry-pick-3230 branch April 5, 2023 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants