Skip to content
Snippets Groups Projects
Commit 30e51f46 authored by Franck Dary's avatar Franck Dary
Browse files

Corrected bug in MacaonDecode where dicts were not closed. Parallel decode.

parent 17e6ebe9
No related branches found
No related tags found
No related merge requests found
#include "MacaonDecode.hpp" #include "MacaonDecode.hpp"
#include <filesystem> #include <filesystem>
#include <execution>
#include "util.hpp" #include "util.hpp"
#include "Decoder.hpp" #include "Decoder.hpp"
#include "Submodule.hpp" #include "Submodule.hpp"
...@@ -122,11 +123,23 @@ int MacaonDecode::main() ...@@ -122,11 +123,23 @@ int MacaonDecode::main()
configs.emplace_back(mcd, tsv, util::utf8string(), std::vector<int>()); configs.emplace_back(mcd, tsv, util::utf8string(), std::vector<int>());
} }
for (unsigned int i = 0; i < configs.size(); i++) machine.setDictsState(Dict::State::Closed);
if (configs.size() > 1)
{ {
decoder.decode(configs[i], beamSize, beamThreshold, debug, printAdvancement); NeuralNetworkImpl::device = torch::kCPU;
configs[i].print(stdout, i == 0); machine.to(NeuralNetworkImpl::device);
std::for_each(std::execution::par_unseq, configs.begin(), configs.end(),
[&decoder, debug, printAdvancement, beamSize, beamThreshold](BaseConfig & config)
{
decoder.decode(config, beamSize, beamThreshold, debug, printAdvancement);
});
} }
else
decoder.decode(configs[0], beamSize, beamThreshold, debug, printAdvancement);
for (unsigned int i = 0; i < configs.size(); i++)
configs[i].print(stdout, i == 0);
} catch(std::exception & e) {util::error(e);} } catch(std::exception & e) {util::error(e);}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment