From e686d1f79e1eb7828c89c7d28b5485408c7cfa7c Mon Sep 17 00:00:00 2001 From: "fmegen@microsoft.com" Date: Wed, 23 Nov 2016 01:06:02 -0800 Subject: [PATCH] addressing CR comments. # Conflicts: # Source/CNTK/BrainScript/BrainScriptEvaluator.cpp # Source/Common/ExceptionWithCallStack.cpp # Source/Common/Include/Config.h # Source/Common/Include/Platform.h # Source/Common/Include/latticearchive.h # Source/Common/Include/numahelpers.h # Source/Math/CPUMatrix.cpp # Source/Math/Matrix.cpp # Source/Math/QuantizedMatrix.cpp --- .../CNTK/BrainScript/BrainScriptEvaluator.cpp | 6 +++-- Source/Common/ExceptionWithCallStack.cpp | 2 ++ Source/Common/Include/Config.h | 1 - Source/Common/Include/Platform.h | 1 - Source/Common/Include/latticearchive.h | 6 ++--- Source/Common/Include/numahelpers.h | 8 +++---- .../ComputationNetwork.cpp | 2 +- .../ConvolutionalNodes.h | 8 +++---- .../InputAndParamNodes.cpp | 2 +- Source/Math/CPUMatrix.cpp | 5 ++-- Source/Math/QuantizedMatrix.cpp | 8 +++---- Source/Readers/BinaryReader/BinaryFile.cpp | 4 ++-- Source/Readers/HTKMLFReader/HTKMLFReader.cpp | 2 +- Source/Readers/HTKMLFReader/htkfeatio.h | 6 ++--- .../Readers/HTKMLFReader/latticearchive.cpp | 24 +++++++++---------- .../HTKMLFReader/rollingwindowsource.h | 2 +- .../LMSequenceReader/SequenceWriter.cpp | 2 +- .../LUSequenceReader/LUSequenceWriter.cpp | 2 +- Source/Readers/UCIFastReader/UCIParser.cpp | 2 +- Source/SGDLib/SGD.cpp | 4 ++-- Source/SGDLib/SimpleEvaluator.h | 2 +- Source/SGDLib/SimpleOutputWriter.h | 6 ++--- 22 files changed, 50 insertions(+), 55 deletions(-) diff --git a/Source/CNTK/BrainScript/BrainScriptEvaluator.cpp b/Source/CNTK/BrainScript/BrainScriptEvaluator.cpp index cf3e083c1..795a749f7 100644 --- a/Source/CNTK/BrainScript/BrainScriptEvaluator.cpp +++ b/Source/CNTK/BrainScript/BrainScriptEvaluator.cpp @@ -18,8 +18,6 @@ #define let const auto #endif -#pragma warning(disable: 4505) // 'function' : unreferenced local function has been removed - namespace Microsoft { namespace MSR { namespace BS { using namespace std; @@ -1151,6 +1149,9 @@ struct Debug : public Object { } }; // fake class type to get the template below trigger + +#pragma warning(push) +#pragma warning(disable : 4505) // 'function' : unreferenced local function has been removed template <> /*static*/ ConfigurableRuntimeType MakeRuntimeTypeConstructor() { @@ -1173,6 +1174,7 @@ template <> rtInfo.isConfigRecord = false; return rtInfo; } +#pragma warning(pop) // ======================================================================= // register ComputationNetwork with the ScriptableObject system diff --git a/Source/Common/ExceptionWithCallStack.cpp b/Source/Common/ExceptionWithCallStack.cpp index b97ce1706..44ae84f5b 100644 --- a/Source/Common/ExceptionWithCallStack.cpp +++ b/Source/Common/ExceptionWithCallStack.cpp @@ -8,8 +8,10 @@ #include "ExceptionWithCallStack.h" #include "Basics.h" #ifdef _WIN32 +#pragma warning(push) #pragma warning(disable: 4091) // 'typedef ': ignored on left of '' when no variable is declared #include "DbgHelp.h" +#pragma warning(pop) #include #endif #include diff --git a/Source/Common/Include/Config.h b/Source/Common/Include/Config.h index d32652d31..43e7e761c 100644 --- a/Source/Common/Include/Config.h +++ b/Source/Common/Include/Config.h @@ -13,7 +13,6 @@ using namespace std; #pragma warning(disable : 4996) // Caused by the TODO below (line ~1280) #pragma warning(disable : 4456) // "declaration of '%$I' hides previous local declaration -#pragma warning(disable : 4477) // format string '%s' requires an argument of type 'unsigned int', but variadic argument 2 has type 'unsigned __int64' // helper for numeric parameter arguments for multiple layers // This parses arguments of the form a:b*n:c where b gets duplicated n times and c unlimited times. diff --git a/Source/Common/Include/Platform.h b/Source/Common/Include/Platform.h index 2dbe8c0d7..88b7b9634 100644 --- a/Source/Common/Include/Platform.h +++ b/Source/Common/Include/Platform.h @@ -13,7 +13,6 @@ #pragma warning(disable: 4458) // declaration of '%$I' hides class member #pragma warning(disable: 4456) // declaration of '%$I' hides previous local declaration -#pragma warning(disable: 4477) // format string '%s' requires an argument of type 'unsigned int', but variadic argument 2 has type 'unsigned __int64' #ifdef _MSC_VER // TODO: thread_local is supported in VS2015. Remove this macro when we uprade to VS2015 diff --git a/Source/Common/Include/latticearchive.h b/Source/Common/Include/latticearchive.h index e8e1908fd..9d2a699ae 100644 --- a/Source/Common/Include/latticearchive.h +++ b/Source/Common/Include/latticearchive.h @@ -24,8 +24,6 @@ #include "simplesenonehmm.h" #include "Matrix.h" -#pragma warning(disable: 4477) // format string '%s' requires an argument of type 'unsigned int', but variadic argument 2 has type 'unsigned __int64' - namespace msra { namespace math { class ssematrixbase; @@ -876,7 +874,7 @@ public: template void dump(FILE* f, const HMMLOOKUPFUNCTION& gethmmname) const // dump a lattice in HTK-like format { - fprintf(f, "N=%lu L=%lu\n", nodes.size(), edges.size()); + fprintf(f, "N=%lu L=%lu\n", (unsigned long)nodes.size(), (unsigned long)edges.size()); // foreach_index (i, nodes) // fprintf (f, "I=%d\tt=%.2f\n", i, nodes[i].t * 0.01f); foreach_index (j, edges) @@ -1283,7 +1281,7 @@ public: char c; uint64_t offset; #ifdef _WIN32 - if (sscanf_s(q, "[%I64u]%c", &offset, &c, sizeof(c)) != 1) + if (sscanf_s(q, "[%I64u]%c", &offset, &c, (unsigned int)sizeof(c)) != 1) #else if (sscanf(q, "[%" PRIu64 "]%c", &offset, &c) != 1) diff --git a/Source/Common/Include/numahelpers.h b/Source/Common/Include/numahelpers.h index aa0d93b75..961422c19 100644 --- a/Source/Common/Include/numahelpers.h +++ b/Source/Common/Include/numahelpers.h @@ -15,8 +15,6 @@ #include "simple_checked_arrays.h" #include "Basics.h" // for FormatWin32Error -#pragma warning(disable : 4477) // format string '%s' requires an argument of type 'unsigned int', but variadic argument 2 has type 'unsigned __int64' - namespace msra { namespace numa { // ... TODO: this can be a 'static', as it should only be set during foreach_node but not outside @@ -139,7 +137,7 @@ static inline void *malloc(size_t n, size_t align) p = VirtualAllocEx(GetCurrentProcess(), NULL, n, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); } if (p == NULL) - fprintf(stderr, "numa::malloc: failed allocating %d bytes with alignment %d\n", n, align); + fprintf(stderr, "numa::malloc: failed allocating %lu bytes with alignment %lu\n", (unsigned long)n, (unsigned long)align); if (((size_t) p) % align != 0) LogicError("VirtualAllocExNuma() returned an address that does not match the alignment requirement"); return p; @@ -163,9 +161,9 @@ static inline void showavailablememory(const char *what) BOOL rc = GetNumaAvailableMemoryNode((UCHAR) i, &availbytes); const double availmb = availbytes / (1024.0 * 1024.0); if (rc) - fprintf(stderr, "%s: %8.2f MB available on NUMA node %d\n", what, availmb, i); + fprintf(stderr, "%s: %8.2f MB available on NUMA node %lu\n", what, availmb, (unsigned long)i); else - fprintf(stderr, "%s: error for getting available memory on NUMA node %d\n", what, i); + fprintf(stderr, "%s: error for getting available memory on NUMA node %lu\n", what, (unsigned long)i); } } diff --git a/Source/ComputationNetworkLib/ComputationNetwork.cpp b/Source/ComputationNetworkLib/ComputationNetwork.cpp index 6d0a6b1f9..6b766000b 100644 --- a/Source/ComputationNetworkLib/ComputationNetwork.cpp +++ b/Source/ComputationNetworkLib/ComputationNetwork.cpp @@ -634,7 +634,7 @@ void ComputationNetwork::SetSeqParam(ComputationNetworkPtr net, /*static*/ void ComputationNetwork::SetMaxTempMemSizeForCNN(ComputationNetworkPtr net, const ComputationNodeBasePtr& criterionNode, const size_t maxTempMemSizeInSamples) { if (maxTempMemSizeInSamples > 0) - fprintf(stderr, "Setting max temp memory size for Convolution operations to %lu samples.\n", maxTempMemSizeInSamples); + fprintf(stderr, "Setting max temp memory size for Convolution operations to %lu samples.\n", (unsigned long)maxTempMemSizeInSamples); list convolutionNodes = net->GetNodesWithType(OperationNameOf(ConvolutionNode), criterionNode); if (convolutionNodes.size() == 0 && maxTempMemSizeInSamples != 0) { diff --git a/Source/ComputationNetworkLib/ConvolutionalNodes.h b/Source/ComputationNetworkLib/ConvolutionalNodes.h index 13ad9d0dc..77264b2d7 100644 --- a/Source/ComputationNetworkLib/ConvolutionalNodes.h +++ b/Source/ComputationNetworkLib/ConvolutionalNodes.h @@ -1080,13 +1080,13 @@ public: auto inputSampleLayout = GetInputSampleLayout(0); char str[4096]; - sprintf(str, "Input[Width:%lu, Height:%lu, Channels:%lu] \n", inputSampleLayout[1], inputSampleLayout[2], inputSampleLayout[0]); + sprintf(str, "Input[Width:%lu, Height:%lu, Channels:%lu] \n", (unsigned long)inputSampleLayout[1], (unsigned long)inputSampleLayout[2], (unsigned long)inputSampleLayout[0]); fstream << string(str); - sprintf(str, "PoolingWindow[Width:%lu, Height:%lu] SubSampling[Horizontal:%lu, Vertical:%lu]\n", m_windowWidth, m_windowHeight, m_horizontalSubsample, m_verticalSubsample); + sprintf(str, "PoolingWindow[Width:%lu, Height:%lu] SubSampling[Horizontal:%lu, Vertical:%lu]\n", (unsigned long)m_windowWidth, (unsigned long)m_windowHeight, (unsigned long)m_horizontalSubsample, (unsigned long)m_verticalSubsample); fstream << string(str); - sprintf(str, "Output[Width:%lu, Height:%lu, Channels:%lu] \n", m_sampleLayout[1], m_sampleLayout[2], m_sampleLayout[0]); + sprintf(str, "Output[Width:%lu, Height:%lu, Channels:%lu] \n", (unsigned long)m_sampleLayout[1], (unsigned long)m_sampleLayout[2], (unsigned long)m_sampleLayout[0]); fstream << string(str); - sprintf(str, "TotalSizePerSample[Input:%lu, Output:%lu] \n", m_inputSizePerSample, m_outputSizePerSample); + sprintf(str, "TotalSizePerSample[Input:%lu, Output:%lu] \n", (unsigned long)m_inputSizePerSample, (unsigned long)m_outputSizePerSample); fstream << string(str); } } diff --git a/Source/ComputationNetworkLib/InputAndParamNodes.cpp b/Source/ComputationNetworkLib/InputAndParamNodes.cpp index b916f3ea5..3e941d119 100644 --- a/Source/ComputationNetworkLib/InputAndParamNodes.cpp +++ b/Source/ComputationNetworkLib/InputAndParamNodes.cpp @@ -614,7 +614,7 @@ template Base::DumpNodeInfo(printValues, printMetadata, fstream); char str[4096]; - sprintf(str, "[%lu,%lu] ", GetAsMatrixNumRows(), GetAsMatrixNumCols()); + sprintf(str, "[%lu,%lu] ", (unsigned long)GetAsMatrixNumRows(), (unsigned long)GetAsMatrixNumCols()); fstream << string(str); sprintf(str, "learningRateMultiplier=%f NeedsGradient=%s", m_learningRateMultiplier, m_learningRateMultiplier>0 ? "true" : "false"); // TODO: update NDL to accept a better matching name as well fstream << string(str); diff --git a/Source/Math/CPUMatrix.cpp b/Source/Math/CPUMatrix.cpp index c5544a603..e802122d9 100644 --- a/Source/Math/CPUMatrix.cpp +++ b/Source/Math/CPUMatrix.cpp @@ -36,7 +36,6 @@ #pragma warning(disable : 4127) // conditional expression is constant; "if (sizeof(ElemType)==sizeof(float))" triggers this #pragma warning(disable : 4244) // unreachable code; triggered for unknown reasons #pragma warning(disable : 4702) // conversion from 'double' to 'float' -#pragma warning(disable : 4477) // format string '%s' requires an argument of type 'unsigned int', but variadic argument 2 has type 'unsigned __int64' #ifdef USE_MKL @@ -3612,9 +3611,9 @@ void CPUMatrix::Print(const char* matrixName, ptrdiff_t rowFirst, ptrd fprintf(stderr, "\n###### "); if (matrixName != nullptr) fprintf(stderr, "%s ", matrixName); - fprintf(stderr, "(%lu, %lu)", GetNumRows(), GetNumCols()); + fprintf(stderr, "(%lu, %lu)", (unsigned long)GetNumRows(), (unsigned long)GetNumCols()); if (rowFirst != 0 || colFirst != 0 || (size_t)(rowLast + 1) != GetNumRows() || (size_t)(colLast + 1) != GetNumCols()) - fprintf(stderr, " [%ld:%ld, %ld:%ld]", rowFirst, rowLast, colFirst, colLast); + fprintf(stderr, " [%ld:%ld, %ld:%ld]", (long)rowFirst, (long)rowLast, (long)colFirst, (long)colLast); fprintf(stderr, " ######\n\n"); if (IsEmpty()) diff --git a/Source/Math/QuantizedMatrix.cpp b/Source/Math/QuantizedMatrix.cpp index 3f0dffde3..ceaee8eef 100644 --- a/Source/Math/QuantizedMatrix.cpp +++ b/Source/Math/QuantizedMatrix.cpp @@ -4,8 +4,6 @@ namespace Microsoft { namespace MSR { namespace CNTK { -#pragma warning(disable: 4477) // format string '%s' requires an argument of type 'unsigned int', but variadic argument 2 has type 'unsigned __int64' - template QuantizedMatrix::QuantizedMatrix(const size_t numRows, const size_t numCols, const size_t nbits, DEVICEID_TYPE deviceId, MemAllocator* allocator /* = nullptr */) : m_numRows(numRows), m_numCols(numCols), m_numBits(nbits), m_allocator(allocator) @@ -129,11 +127,11 @@ void QuantizedMatrix::Print(const char* matrixName, size_t rowStart, s } if (matrixName != nullptr) - fprintf(stderr, "\n###### %s (%lu, %lu) ######\n", matrixName, GetNumRows(), GetNumCols()); + fprintf(stderr, "\n###### %s (%lu, %lu) ######\n", matrixName, (unsigned long)GetNumRows(), (unsigned long)GetNumCols()); else - fprintf(stderr, "\n###### Unnamed Matrix (%lu, %lu) ######\n", GetNumRows(), GetNumCols()); + fprintf(stderr, "\n###### Unnamed Matrix (%lu, %lu) ######\n", (unsigned long)GetNumRows(), (unsigned long)GetNumCols()); - fprintf(stderr, "\n------ Print Range (%lu:%lu, %lu:%lu) ------\n", rowStart, rowEnd, colStart, colEnd); + fprintf(stderr, "\n------ Print Range (%lu:%lu, %lu:%lu) ------\n", (unsigned long)rowStart, (unsigned long)rowEnd, (unsigned long)colStart, (unsigned long)colEnd); for (size_t j = colStart; j <= colEnd; j++) { diff --git a/Source/Readers/BinaryReader/BinaryFile.cpp b/Source/Readers/BinaryReader/BinaryFile.cpp index 3f28be941..d012f18ab 100644 --- a/Source/Readers/BinaryReader/BinaryFile.cpp +++ b/Source/Readers/BinaryReader/BinaryFile.cpp @@ -118,7 +118,7 @@ void BinaryFile::SetFilePositionMax(size_t filePositionMax) if (m_filePositionMax > m_mappedSize) { char message[128]; - sprintf_s(message, "Setting max position larger than mapped file size: %ld > %ld", m_filePositionMax, m_mappedSize); + sprintf_s(message, "Setting max position larger than mapped file size: %ld > %ld", (long)m_filePositionMax, (long)m_mappedSize); RuntimeError(message); } } @@ -508,7 +508,7 @@ Section* Section::ReadSection(size_t index, MappingType mapping, size_t sizeElem if (!section->ValidateHeader()) { char message[256]; - sprintf_s(message, "Invalid header in file %ls, in header %s\n", m_file->GetName().c_str(), section->GetName().c_str()); + sprintf_s(message, "Invalid header in file %ls, in header %ls\n", m_file->GetName().c_str(), section->GetName().c_str()); RuntimeError(message); } diff --git a/Source/Readers/HTKMLFReader/HTKMLFReader.cpp b/Source/Readers/HTKMLFReader/HTKMLFReader.cpp index 5c9c55c2a..debd5a320 100644 --- a/Source/Readers/HTKMLFReader/HTKMLFReader.cpp +++ b/Source/Readers/HTKMLFReader/HTKMLFReader.cpp @@ -363,7 +363,7 @@ void HTKMLFReader::PrepareForTrainingOrTesting(const ConfigRecordType& n++; } - fprintf(stderr, " %lu entries\n", n); + fprintf(stderr, " %lu entries\n", (unsigned long)n); if (i == 0) numFiles = n; diff --git a/Source/Readers/HTKMLFReader/htkfeatio.h b/Source/Readers/HTKMLFReader/htkfeatio.h index de76a4ef6..d381e567c 100644 --- a/Source/Readers/HTKMLFReader/htkfeatio.h +++ b/Source/Readers/HTKMLFReader/htkfeatio.h @@ -934,7 +934,7 @@ class htkmlfreader : public map> // [key][i] the data if (filename.length() < 3 || filename[0] != '"' || filename[filename.length() - 1] != '"') { fprintf(stderr, "warning: filename entry (%s)\n", filename.c_str()); - fprintf(stderr, "skip current mlf entry from line (%lu) until line (%lu).\n", line + idx, line + lines.size()); + fprintf(stderr, "skip current mlf entry from line (%lu) until line (%lu).\n", (unsigned long)(line + idx), (unsigned long)(line + lines.size())); return; } @@ -1174,7 +1174,7 @@ public: malformed("unexpected end in mid-utterance"); curpath.clear(); - fprintf(stderr, " total %lu entries\n", this->size()); + fprintf(stderr, " total %lu entries\n", (unsigned long)this->size()); } // read state list, index is from 0 @@ -1195,7 +1195,7 @@ public: RuntimeError("readstatelist: lines (%d) not equal to statelistmap size (%d)", (int) index, (int) statelistmap.size()); if (statelistmap.size() != issilstatetable.size()) RuntimeError("readstatelist: size of statelookuparray (%d) not equal to statelistmap size (%d)", (int) issilstatetable.size(), (int) statelistmap.size()); - fprintf(stderr, "total %lu state names in state list %ls\n", statelistmap.size(), stateListPath.c_str()); + fprintf(stderr, "total %lu state names in state list %ls\n", (unsigned long)statelistmap.size(), stateListPath.c_str()); } } diff --git a/Source/Readers/HTKMLFReader/latticearchive.cpp b/Source/Readers/HTKMLFReader/latticearchive.cpp index 743849587..e2a8819a6 100644 --- a/Source/Readers/HTKMLFReader/latticearchive.cpp +++ b/Source/Readers/HTKMLFReader/latticearchive.cpp @@ -156,7 +156,7 @@ static size_t tryfind(const MAPTYPE &map, const KEYTYPE &key, VALTYPE deflt) // TODO: This is sort of redundant now--it gets the symmap from the HMM, i.e. always the same for all archives. writeunitmap(symlistpath, modelsymmap); - fprintf(stderr, "completed %lu out of %lu lattices (%lu read failures, %.1f%%)\n", infiles.size(), infiles.size() - brokeninputfiles, brokeninputfiles, 100.0f * brokeninputfiles / infiles.size()); + fprintf(stderr, "completed %lu out of %lu lattices (%lu read failures, %.1f%%)\n", (unsigned long)infiles.size(), (unsigned long)(infiles.size() - brokeninputfiles), (unsigned long)brokeninputfiles, 100.0f * brokeninputfiles / infiles.size()); } // helper to set a context value (left, right) with checking of uniqueness @@ -206,7 +206,7 @@ vector lattice::determinenodecontexts(const msra::asr::sim // ends with n = position of furthest non-sp if (n < 0) // only sp? RuntimeError("determinenodecontexts: word consists only of /sp/"); - fprintf(stderr, "determinenodecontexts: word with %lu /sp/ at the end found, edge %d\n", a.size() - 1 - n, j); + fprintf(stderr, "determinenodecontexts: word with %lu /sp/ at the end found, edge %d\n", (unsigned long)a.size() - 1 - n, j); multispseen++; Z = a[n].unit; } @@ -231,7 +231,7 @@ vector lattice::determinenodecontexts(const msra::asr::sim nodecontexts[E].setleft(Zid); } if (multispseen > 0) - fprintf(stderr, "determinenodecontexts: %lu broken edges in %lu with multiple /sp/ at the end seen\n", multispseen, edges.size()); + fprintf(stderr, "determinenodecontexts: %lu broken edges in %lu with multiple /sp/ at the end seen\n", (unsigned long)multispseen, (unsigned long)edges.size()); // check CI conditions and put in 't' // We make the hard assumption that there is only one CI phone, /sil/. const auto &silhmm = hset.gethmm(silunit); @@ -325,7 +325,7 @@ void lattice::merge(const lattice &other, const msra::asr::simplesenonehmm &hset if (contexts[i].iother != SIZE_MAX) othernodemap[contexts[i].iother] = j - 1; } - fprintf(stderr, "merge: joint node space uniq'ed to %d from %d\n", j, contexts.size()); + fprintf(stderr, "merge: joint node space uniq'ed to %d from %d\n", j, (unsigned long)contexts.size()); contexts.resize(j); // create a new node array (just copy the contexts[].t fields) @@ -384,7 +384,7 @@ void lattice::dedup() } edges2[k++] = edges2[j]; } - fprintf(stderr, "dedup: edges reduced to %d from %d\n", k, edges2.size()); + fprintf(stderr, "dedup: edges reduced to %lu from %lu\n", (unsigned long)k, (unsigned long)edges2.size()); edges2.resize(k); info.numedges = edges2.size(); edges.clear(); // (should already be, but isn't; make sure we no longer use it) @@ -517,13 +517,13 @@ void lattice::dedup() } } // end for (toclines) if (skippedmerges > 0) - fprintf(stderr, "convert: %d out of %d merge operations skipped due to secondary lattice missing\n", skippedmerges, toclines.size()); + fprintf(stderr, "convert: %lu out of %lu merge operations skipped due to secondary lattice missing\n", (unsigned long)skippedmerges, (unsigned long)toclines.size()); // write out the updated unit map if (f && ftoc) writeunitmap(symlistpath, modelsymmap); - fprintf(stderr, "converted %d lattices\n", toclines.size()); + fprintf(stderr, "converted %lu lattices\n", (unsigned long)toclines.size()); } // --------------------------------------------------------------------------- @@ -544,7 +544,7 @@ void lattice::fromhtklattice(const wstring &path, const std::unordered_map::ReadLabelInfo(const wstring& vocfile, b = 0; while (!feof(vin)) { - fscanf_s(vin, "%s\n", stmp, _countof(stmp)); + fscanf_s(vin, "%s\n", stmp, (unsigned int)_countof(stmp)); word4idx[stmp] = b; idx4word[b++] = stmp; } diff --git a/Source/Readers/LUSequenceReader/LUSequenceWriter.cpp b/Source/Readers/LUSequenceReader/LUSequenceWriter.cpp index e3276085c..543c9be26 100644 --- a/Source/Readers/LUSequenceReader/LUSequenceWriter.cpp +++ b/Source/Readers/LUSequenceReader/LUSequenceWriter.cpp @@ -70,7 +70,7 @@ void LUSequenceWriter::ReadLabelInfo(const wstring& vocfile, b = 0; while (!feof(vin)) { - fscanf_s(vin, "%s\n", stmp, _countof(stmp)); + fscanf_s(vin, "%s\n", stmp, (int)_countof(stmp)); word4idx[stmp] = b; idx4word[b++] = stmp; } diff --git a/Source/Readers/UCIFastReader/UCIParser.cpp b/Source/Readers/UCIFastReader/UCIParser.cpp index f05897dfe..568e6e2f6 100644 --- a/Source/Readers/UCIFastReader/UCIParser.cpp +++ b/Source/Readers/UCIFastReader/UCIParser.cpp @@ -679,7 +679,7 @@ long UCIParser::Parse(size_t recordsRequested, std::vector 2) - fprintf(stderr, "\n%ld ms, %ld numbers parsed\n\n", TickDelta, m_totalNumbersConverted); + fprintf(stderr, "\n%ld ms, %ld numbers parsed\n\n", TickDelta, (long)m_totalNumbersConverted); return recordCount; } diff --git a/Source/SGDLib/SGD.cpp b/Source/SGDLib/SGD.cpp index 92a2ab0db..463f5737b 100644 --- a/Source/SGDLib/SGD.cpp +++ b/Source/SGDLib/SGD.cpp @@ -741,7 +741,7 @@ void SGD::TrainOrAdaptModel(int startEpoch, ComputationNetworkPtr net, for (int j = 1; j < m_learnRateAdjustInterval; j++) { int epochToDelete = i - j; - LOGPRINTF(stderr, "SGD: removing model and checkpoint files for epoch %d after rollback to epoch %lu\n", epochToDelete + 1, (size_t)(i - m_learnRateAdjustInterval) + 1); // report 1 based epoch number + LOGPRINTF(stderr, "SGD: removing model and checkpoint files for epoch %d after rollback to epoch %lu\n", epochToDelete + 1, (unsigned long)(i - m_learnRateAdjustInterval) + 1); // report 1 based epoch number _wunlink(GetModelNameForEpoch(epochToDelete).c_str()); _wunlink(GetCheckPointFileNameForEpoch(epochToDelete).c_str()); } @@ -1548,7 +1548,7 @@ bool SGD::PreCompute(ComputationNetworkPtr net, } fprintf(stderr, "\n"); - LOGPRINTF(stderr, "Precomputing --> %lu PreCompute nodes found.\n\n", nodes.size()); + LOGPRINTF(stderr, "Precomputing --> %lu PreCompute nodes found.\n\n", (unsigned long)nodes.size()); if (m_traceLevel > 0) { for (const auto & node : nodes) diff --git a/Source/SGDLib/SimpleEvaluator.h b/Source/SGDLib/SimpleEvaluator.h index a3f3e5753..69650906d 100644 --- a/Source/SGDLib/SimpleEvaluator.h +++ b/Source/SGDLib/SimpleEvaluator.h @@ -290,7 +290,7 @@ protected: void DisplayEvalStatistics(const size_t startMBNum, const size_t endMBNum, const size_t numSamplesLastLogged, const vector& evalNodes, const vector& evalResults, const vector& evalResultsLastLogged, bool displayConvertedValue = false, bool isFinal = false) { - LOGPRINTF(stderr, "%sMinibatch[%lu-%lu]: ", isFinal ? "Final Results: " : "", startMBNum, endMBNum); + LOGPRINTF(stderr, "%sMinibatch[%lu-%lu]: ", isFinal ? "Final Results: " : "", (unsigned long)startMBNum, (unsigned long)endMBNum); for (size_t i = 0; i < evalResults.size(); i++) { diff --git a/Source/SGDLib/SimpleOutputWriter.h b/Source/SGDLib/SimpleOutputWriter.h index 7af17f3d3..7accba1cb 100644 --- a/Source/SGDLib/SimpleOutputWriter.h +++ b/Source/SGDLib/SimpleOutputWriter.h @@ -92,7 +92,7 @@ public: } if (m_verbosity > 0) - fprintf(stderr, "Total Samples Evaluated = %lu\n", totalEpochSamples); + fprintf(stderr, "Total Samples Evaluated = %lu\n", (unsigned long)totalEpochSamples); // clean up } @@ -268,7 +268,7 @@ public: } totalEpochSamples += actualMBSize; - fprintf(stderr, "Minibatch[%lu]: ActualMBSize = %lu\n", numMBsRun, actualMBSize); + fprintf(stderr, "Minibatch[%lu]: ActualMBSize = %lu\n", (unsigned long)numMBsRun, (unsigned long)actualMBSize); if (outputPath == L"-") // if we mush all nodes together on stdout, add some visual separator fprintf(stdout, "\n"); @@ -285,7 +285,7 @@ public: fprintfOrDie(f, "%s", formattingOptions.epilogue.c_str()); } - fprintf(stderr, "Written to %ls*\nTotal Samples Evaluated = %lu\n", outputPath.c_str(), totalEpochSamples); + fprintf(stderr, "Written to %ls*\nTotal Samples Evaluated = %lu\n", outputPath.c_str(), (unsigned long)totalEpochSamples); // flush all files (where we can catch errors) so that we can then destruct the handle cleanly without error for (auto & iter : outputStreams)