-
Notifications
You must be signed in to change notification settings - Fork 5.4k
support load kaldi model in python #3976
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
Conversation
|
What is the problem with GetComponent() |
|
Hi, Dan, I have tested nnet3-compute.cc completely. |
|
That is because |
|
should I Wrap all below Component? Is there an easiest way? |
|
Please refer to
for how to wrap overloaded methods. |
|
It is needed if you want to build a nnet3 model from a config file. Note that it is a static method. |
|
Please refer to
for how to wrap static methods. Note that in your case, the function returns a pointer. You have to use the flag |
|
I would hope it would be possible to wrap only the base-class of Component
(and maybe one or two other classes in that hierarchy, but not all of them).
…On Wed, Mar 4, 2020 at 12:47 PM Fangjun Kuang ***@***.***> wrote:
Please refer to
https://github.com/kaldi-asr/kaldi/blob/cc63cca97ecd4b54d1b3f1dd9994a3117c999404/src/pybind/fstext/lattice_weight_pybind.cc#L80
for how to wrap static methods.
Note that in your case, the function returns a pointer. You have to use
the flag
take_ownership.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3976?email_source=notifications&email_token=AAZFLO2OXS6YQ32S7IWBDOLRFXMMHA5CNFSM4LA2TCN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENWKZGQ#issuecomment-594324634>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZFLO5CWMII4FOJHUGVFJ3RFXMMHANCNFSM4LA2TCNQ>
.
|
will do the job. You do NOT need to wrap other components to wrap this function. |
|
If you have time, please write a |
|
Should I wrap init a nnet3 model from a config file? I want a nnet3 model just readed from a binary model file. and this give me an error msg |
what is the function type that you're trying to convert to? |
The example I gave is for a global function. In your case, it is a class member function. |
|
|
|
Note that what kaldi-onnx dose. And I want to get a dict from kaldi's model file like the code below. So I suspect that I can use |
|
Can
|
|
As you can see from the following Lines 128 to 133 in cc63cca
You can use either .def("GetComponent", (Component* (PyClass::*)(int32) )&PyClass::GetComponent, py::arg("c"),py::return_value_policy::reference)or .def("GetComponent", (const Component* (PyClass::*)(int32) const )&PyClass::GetComponent, py::arg("c"), py::arg("c"),py::return_value_policy::reference)Or you can use both. Since the return type is kaldi/src/nnet3/nnet-component-itf.h Line 114 in cc63cca
|
|
@fanlu |
|
|
Nnet3Parser(f).run()
|
|
Is the conversion process slow? |
|
You can split |
|
the time of conversion and runtime are 0.0004012584686279297s and 97.50831198692322s, respectively |
Please refer to the above comment. |
|
Please mark a comment as resolved when it is done. |
|
because in class should I implement a new method like
|
|
@fanlu
Please show me the return type in Python using |
|
|
I think it is a mistake in the c++ code to use kaldi/src/nnet3/nnet-convolutional-component.h Lines 554 to 558 in cc63cca
@danpovey |
|
the same style in class LinearComponent |
What is the type of |
|
|
For the following program class Base {
public:
virtual std::string Hello() const = 0;
virtual ~Base() = default;
protected:
Base() = default;
};
class Child : public Base {
public:
Child() = default;
std::string Hello() const override { return "hello"; }
};
class Test {
public:
Test() = default;
const Base& GetChild() const { return c_; }
private:
Child c_;
};The return type of Please check your code again. It should return a type of |
|
+1 |
* support load kaldi model in python * add some component * split one file to multi component wrap files * fix some bugs and add test mdl * add testmode func in batchnorm pybind * change StatsSum StatsSumsq to Mean Var * make const

@csukuangfj I have test all calculation between kaldi tdnn_1c's model and pytorch kernel(2,2) model, the previous issue is talked in this pr #3940
After load kaldi model to pytorch, we can get similar result now.
First, I use tool to do this load job, but it's too slow.
So I want to implement a pybind function to load kaldi's model. And this is more intuitive. What do you think?
But I have problem with
GetComponentnow, sorry about that I am not good at pybind11 and C++.If you have time, please help me or give me some hint to do this job. Thanks
Thanks for @csukuangfj 's help, it is worked.