debug Broadcast - show max length and active batch max length

This commit is contained in:
Hieu Hoang 2018-01-20 16:06:44 +00:00
parent 7e78a6a155
commit 434303d233
2 changed files with 13 additions and 4 deletions

View File

@ -202,7 +202,6 @@ private:
using namespace mblas;
BEGIN_TIMER("GetAlignedSourceContext");
unsigned maxLength = SourceContext.dim(0);
unsigned batchSize = SourceContext.dim(3);
std::vector<unsigned> hypo2Batch = histories.Hypo2Batch();
@ -216,9 +215,9 @@ private:
BroadcastVec(_1 + _2, Temp2_, *w_.B_/*, s_[1]*/);
}
Broadcast(Tanh(_1 + _2), Temp1_, SCU, Temp2_, dHypo2Batch_, maxLength);
Broadcast(Tanh(_1 + _2), Temp1_, SCU, Temp2_, dHypo2Batch_, histories.MaxLength());
TIME_CMD("Prod4", Prod(A_, *w_.V_, Temp1_, true));
Prod(A_, *w_.V_, Temp1_, true);
BEGIN_TIMER("Softmax");
mblas::Softmax(A_, dHypo2Batch_, sentenceLengths, batchSize);

View File

@ -171,9 +171,10 @@ Matrix& Broadcast(Functor functor,
const Matrix& in1,
const Matrix& in2,
const mblas::Vector<unsigned>& hypo2Batch,
unsigned srcSize)
unsigned activeBatchMaxLength)
{
BEGIN_TIMER("Broadcast");
unsigned srcSize = in1.dim(0);
unsigned sumOfBeamSizes = in2.dim(0);
//unsigned rows = srcSize * sumOfBeamSizes;
@ -181,6 +182,15 @@ Matrix& Broadcast(Functor functor,
out.NewSize(srcSize, cols, sumOfBeamSizes);
/*
std::cerr << "out=" << out.Debug(0) << std::endl;
std::cerr << "in1=" << in1.Debug(0) << std::endl;
std::cerr << "in2=" << in2.Debug(0) << std::endl;
std::cerr << "hypo2Batch=" << hypo2Batch.Debug(0) << std::endl;
*/
std::cerr << "srcSize=" << srcSize << " " << activeBatchMaxLength << std::endl;
//std::cerr << std::endl;
unsigned size = out.size();
unsigned threads = std::min(MAX_THREADS, size);
unsigned blocks = (size / threads) + ((size % threads == 0) ? 0 : 1);