mirror of
https://github.com/marian-nmt/marian.git
synced 2024-09-11 06:15:56 +03:00
setGuidedAlignment() now accepts an rvalue ref; reenabled the findBatchSize() sanity check, since it makes no runtime difference; added quicksand sources to VS Project
This commit is contained in:
parent
491c9517cd
commit
c477031fae
@ -24,7 +24,7 @@ public:
|
||||
const std::vector<size_t>& getSentenceIds() const { return sentenceIds_; }
|
||||
void setSentenceIds(const std::vector<size_t>& ids) { sentenceIds_ = ids; }
|
||||
|
||||
virtual void setGuidedAlignment(const std::vector<float>&) = 0;
|
||||
virtual void setGuidedAlignment(std::vector<float>&&) = 0;
|
||||
virtual void setDataWeights(const std::vector<float>&) = 0;
|
||||
|
||||
protected:
|
||||
|
@ -141,7 +141,8 @@ private:
|
||||
lengths[i] = batchVector.back()[i].size(); // record max lengths so far
|
||||
|
||||
maxBatchSize = stats_->findBatchSize(lengths, cachedStatsIter);
|
||||
#if 0 // sanity check: would we find the same entry if searching from the start?
|
||||
// this optimization makes no difference indeed
|
||||
#if 1 // sanity check: would we find the same entry if searching from the start?
|
||||
auto it = stats_->lower_bound(lengths);
|
||||
auto maxBatchSize1 = stats_->findBatchSize(lengths, it);
|
||||
ABORT_IF(maxBatchSize != maxBatchSize1, "findBatchSize iter caching logic is borked");
|
||||
|
@ -232,7 +232,7 @@ void CorpusBase::addAlignmentsToBatch(Ptr<CorpusBatch> batch,
|
||||
aligns[idx] = 1.f;
|
||||
}
|
||||
}
|
||||
batch->setGuidedAlignment(aligns);
|
||||
batch->setGuidedAlignment(std::move(aligns));
|
||||
}
|
||||
|
||||
void CorpusBase::addWeightsToBatch(Ptr<CorpusBatch> batch,
|
||||
|
@ -328,7 +328,7 @@ public:
|
||||
if(options->get("guided-alignment", std::string("none")) != "none") {
|
||||
std::vector<float> alignment(batchSize * lengths.front() * lengths.back(),
|
||||
0.f);
|
||||
batch->setGuidedAlignment(alignment);
|
||||
batch->setGuidedAlignment(std::move(alignment));
|
||||
}
|
||||
|
||||
if(options->has("data-weighting")) {
|
||||
@ -403,7 +403,7 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
cb->setGuidedAlignment(aligns);
|
||||
cb->setGuidedAlignment(std::move(aligns));
|
||||
pos += dimBatch;
|
||||
}
|
||||
}
|
||||
@ -438,8 +438,8 @@ public:
|
||||
}
|
||||
|
||||
std::vector<float>& getGuidedAlignment() { return guidedAlignment_; }
|
||||
void setGuidedAlignment(const std::vector<float>& aln) override {
|
||||
guidedAlignment_ = aln;
|
||||
void setGuidedAlignment(std::vector<float>&& aln) override {
|
||||
guidedAlignment_ = std::move(aln);
|
||||
}
|
||||
|
||||
std::vector<float>& getDataWeights() { return dataWeights_; }
|
||||
|
@ -141,6 +141,7 @@
|
||||
<ClCompile Include="..\src\3rd_party\svd\svd.cpp" />
|
||||
<ClCompile Include="..\src\layers\loss.cpp" />
|
||||
<ClCompile Include="..\src\layers\weight.cpp" />
|
||||
<ClCompile Include="..\src\microsoft\quicksand.cpp" />
|
||||
<ClCompile Include="..\src\tensors\backend.cpp" />
|
||||
<ClCompile Include="..\src\tensors\cpu\device.cpp" />
|
||||
<ClCompile Include="..\src\tensors\cpu\dropout.cpp" />
|
||||
@ -404,6 +405,7 @@
|
||||
<ClInclude Include="..\src\layers\generic.h" />
|
||||
<ClInclude Include="..\src\layers\guided_alignment.h" />
|
||||
<ClInclude Include="..\src\layers\word2vec_reader.h" />
|
||||
<ClInclude Include="..\src\microsoft\quicksand.h" />
|
||||
<ClInclude Include="..\src\models\amun.h" />
|
||||
<ClInclude Include="..\src\models\char_s2s.h" />
|
||||
<ClInclude Include="..\src\models\costs.h" />
|
||||
|
@ -253,6 +253,9 @@
|
||||
<ClCompile Include="..\src\common\config_validator.cpp">
|
||||
<Filter>common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\microsoft\quicksand.cpp">
|
||||
<Filter>microsoft</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\src\marian.h" />
|
||||
@ -1067,6 +1070,9 @@
|
||||
<ClInclude Include="..\src\common\types.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\microsoft\quicksand.h">
|
||||
<Filter>microsoft</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="3rd_party">
|
||||
@ -1183,6 +1189,9 @@
|
||||
<Filter Include="command">
|
||||
<UniqueIdentifier>{c6b3323a-0df3-4129-9a66-e93cea668604}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="microsoft">
|
||||
<UniqueIdentifier>{bf291eae-3de9-4294-b5aa-07ab631951e1}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include=".editorConfig" />
|
||||
|
Loading…
Reference in New Issue
Block a user