Skip to content

Commit

Permalink
Merged PR 13084: Fix minor regressions in master branch
Browse files Browse the repository at this point in the history
Fix minor regressions in master branch
  • Loading branch information
ykim362 committed May 27, 2020
1 parent 6d2bfa6 commit 51b13bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/models/transformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class Transformer : public EncoderOrDecoderBase {
// according to paper embeddings are scaled up by \sqrt(d_m)
embeddings = std::sqrt((float)dimEmb) * embeddings; // embeddings were initialized to unit length; so norms will be in order of sqrt(dimEmb)

#ifdef USE_ONNX // TODO 'Sin' op and constant sine generate different result. So, use constant when 'USE_ONNX' is not defined for now.
// precompute the arguments to sin() (the cos(x) are expressed as sin(x+pi/2))
if (sinusoidalEmbeddingsFreq_.empty()) {
auto numTimescales = dimEmb / 2;
Expand All @@ -100,6 +101,10 @@ class Transformer : public EncoderOrDecoderBase {
auto positionRange = graph_->constant({ dimWords, 1, 1 }, inits::range((float)start, (float)start + (float)dimWords));
positionRange->set_name("data_" + std::to_string(batchIndex_) + "_posrange");
auto signal = sin(positionRange * frequencies + cosOffsets);
#else // USE_ONNX
auto signal = graph_->constant({dimWords, 1, dimEmb},
inits::sinusoidalPositionEmbeddings(start));
#endif // USE_ONNX

embeddings = embeddings + signal;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tensors/cpu/prod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void ProdBatched(marian::Tensor C,
auto strideC = n * m;

auto batchC = std::max(batchA, batchB);
#if MKL_FOUND
#if 0 // TODO Accuracy regression. Batched GEMM generate different output. Investigating and disable for now.
CBLAS_TRANSPOSE transA_forarr = CblasNoTrans;
CBLAS_TRANSPOSE transB_forarr = CblasNoTrans;

Expand Down

0 comments on commit 51b13bb

Please sign in to comment.