-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Support for both OpenFST 1.7.3 and 1.8.2 #4927
Conversation
So, on linux the tests fail to compile with the same error. So I guess it's not just apple/clang weirdness. |
Let me help you. You can change
from
to
By the way, if you need to support multiple openfst versions, then you can do
|
HINT:
|
The test is failing because of line src/fstextra/lattice-utils-test.cc:109 // since semiring is idempotent, this should succeed too.
std::cout << "Distance: " << ShortestDistance(cfst) << " x " << ShortestDistance(nbest_fst_1b) << std::endl;
assert(ApproxEqual(ShortestDistance(cfst),
ShortestDistance(nbest_fst_1b)));
The output is:
NB: I was able to repro it on another machine/distro. |
Full log from the test |
Have you fixed it? |
I didn't, yet, apologies. I might be able to do it next week.
Or if you want to take a stab at it...?
Y.
…On Wed, Jul 31, 2024 at 04:44 Fangjun Kuang ***@***.***> wrote:
Full log from the test lattice-utils-test.testlog.txt
<https://github.com/user-attachments/files/16380954/lattice-utils-test.testlog.txt>
Have you fixed it?
—
Reply to this email directly, view it on GitHub
<#4927 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACUKYXZ5U7W6XI4XAGESXYDZPBFRXAVCNFSM6AAAAABLOEXNFCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJZGUZTEMJTGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@@ -172,7 +172,8 @@ int main(int argc, char *argv[]) { | |||
if (g_kaldi_verbose_level >= 2) { | |||
KALDI_LOG << "phn2word FST is below:"; | |||
fst::FstPrinter<StdArc> fstprinter(phn2word, NULL, NULL, NULL, false, true, "\t"); | |||
fstprinter.Print(&std::cerr, "standard error"); | |||
printer_print(std::cerr, fstprinter, "standard error"); | |||
//fstprinter.Print(&std::cerr, "standard error"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this?
fst::StdCompactAcceptorFst cfst(fst); | ||
cfst.Write(os, write_options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this pre-1.8 compatible? Should we go flat out 1.8+? We've had the version of OpenFST fixed pretty much forever.
if [ $OPENFST_VER_NUM -lt 10800 ]; then | ||
echo "CXXLANGVERSION = c++14" | ||
else | ||
echo "CXXLANGVERSION = c++17" | ||
fi >> kaldi.mk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you think of a case when we would run into a pre-C++14 compiler? Maybe it's time to go C++17 unconditionally?
#include "fstext/fst-test-utils.h" | ||
#include "base/kaldi-math.h" | ||
|
||
#include "fstext/openfst_compat.h" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sort #include
s alphabetically. Or, if openfst_compat.h
requires being included the last, then add a comment to that effect.
for (SymbolTable::iterator iter = symtab.begin(); | ||
iter != symtab.end(); | ||
++iter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that would have been for (SymbolTable::iterator iter : symtab)
in C++17 ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to use auto with range based for here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can argue with @danpovey about this.🙂
In this particular case, I agree with you. My own rule of thumb is, if the real or conceptual type is obvious, use either auto
; otherwise, the type must be explicit. In this case, the conceptual type, namely the iterator, is obvious. But Dan wants explicit types, with an exception for extreme ugliness of their explicit spelling, I believe.
#ifndef KALDI_FSTEXT_OPENFST_COMPAT_H | ||
#define KALDI_FSTEXT_OPENFST_COMPAT_H | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <fst/flags.h>
is for the one below, only if you like it better.
<utility>
is for std::forward
. std::string
is used in printer_print
.
#include <fst/arc-map.h> | |
#include <fst/flags.h> | |
#include <string> | |
#include <utility> |
|
||
|
||
#if OPENFST_VER < 10800 | ||
#define FST_FLAGS_fst_weight_separator FLAGS_fst_weight_separator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be a bit C++ish than the macros (https://godbolt.org/z/n5roPYzET):
#define FST_FLAGS_fst_weight_separator FLAGS_fst_weight_separator | |
DECLARE_string(fst_weight_separator); | |
inline constexpr std::string& FST_FLAGS_fst_weight_separator = | |
FLAGS_fst_weight_separator; |
To your liking, anyway. Either is fine.
return ArcMap(std::forward<Args>(args)...); | ||
} | ||
|
||
using MapFstOptions=ArcMapFstOptions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using MapFstOptions=ArcMapFstOptions; | |
using MapFstOptions = ArcMapFstOptions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest that clang-format
should be used to format the file automagically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@csukuangfj, I suggest the same… I mean, feel free… 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guys, the focus here is on getting something committed that won't break things, we're in maintenance mode so it's not the time to worry too much about how it looks.
@@ -235,8 +235,13 @@ inline bool HasBannedPrefixPlusDigits(SymbolTable *symTable, std::string prefix, | |||
assert(symTable != NULL); | |||
const char *prefix_ptr = prefix.c_str(); | |||
size_t prefix_len = strlen(prefix_ptr); // allowed to be zero but not encouraged. | |||
#if OPENFST_VER >= 10800 | |||
for (SymbolTable::iterator siter = symTable->begin(); siter != symTable->end(); ++siter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Past 80.
for (SymbolTable::iterator siter = symTable->begin(); siter != symTable->end(); ++siter) { | |
for (SymbolTable::iterator siter = symTable->begin(); | |
siter != symTable->end(); ++siter) { |
@@ -24,7 +24,7 @@ | |||
|
|||
namespace kaldi { | |||
|
|||
typedef kaldi::int32 int32; | |||
typedef int32 int32; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks weird. Is it still required? IIRC, this was a workaround for a bug in MS compiler 10 years ago. I may be totally wrong, tho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say it's likely not required, probably this is from a sed replace operation.
I can take a stab at it tomorrow… To be more precise, it's like 6 in the morning here, and it's still "today", so tomorrow can be any time within 24h from now... |
I had my wife check that it compiles for her and it was OK. I want to keep this moving or people will become dispirited from the slow progress, so I'll merge this and if there are problems we'll fix them later. |
Wait, I see there's a test failing, let me see if I can fix it. |
Does anyone have time to run the tests locally and see what the output of the failing test (lattice-utils-test I think) is? |
The issue does not seem to happen with OpenFST 1.7.2. Trying with 1.8.3 which is what the failed test ran with. |
OK, I have not been able to reproduce the issue with openfst-1.8.3 because of this: |
Weird, I cannot reproduce the issue either. I'm confused, but hey, at least
it's working
y.
…On Sun, Sep 8, 2024 at 9:32 AM Daniel Povey ***@***.***> wrote:
Merged #4927 <#4927> into master.
—
Reply to this email directly, view it on GitHub
<#4927 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACUKYX6VSMOCVKPEZSILL63ZVP4RVAVCNFSM6AAAAABLOEXNFCVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJUGE3TGNBXGI2TANI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
we could perhaps add something to the github actions to cat the .testlog
file to the screen on failing test?
…On Mon, Sep 9, 2024 at 4:53 PM jtrmal ***@***.***> wrote:
Weird, I cannot reproduce the issue either. I'm confused, but hey, at
least
it's working
y.
On Sun, Sep 8, 2024 at 9:32 AM Daniel Povey ***@***.***>
wrote:
> Merged #4927 <#4927> into
master.
>
> —
> Reply to this email directly, view it on GitHub
> <#4927 (comment)>, or
> unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/ACUKYX6VSMOCVKPEZSILL63ZVP4RVAVCNFSM6AAAAABLOEXNFCVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJUGE3TGNBXGI2TANI>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
—
Reply to this email directly, view it on GitHub
<#4927 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZFLO3DB5NRE4XUOV3NEJDZVVOZ7AVCNFSM6AAAAABLOEXNFCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZXGUZDIMBSGU>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
I'll do my best to look at it today. As soon as I crawl out of the comms closet. Looks like I got me my Internet back... |
I added a thin compatibility layer (and a few ifdefs)
By default the build infrastructure uses OpenFST-1.7.2 and there should be no change compared to current pipelines.
It is however switch the openFst version while making
/tools
like so:and after that the version should be picked up by
configure
(also to be re-run) and flags will be appropriately defined. Will be grateful for reviews/testing --so far I tested only on Apple M3For 1.8.3, not all tests will compile. There are two outstanding tests failing to compile with this error:
if anyone can help me figure out the issue, I will be grateful
cc: @georgthegreat @mmcauliffe