virtual void Validate(bool isFinalValidationPass) override { .... if (isFinalValidationPass && !(Input(0)->GetSampleMatrixNumRows() == Input(2)->GetSampleMatrixNumRows() && (Input(0)->GetMBLayout() == Input(2)->GetMBLayout() || !Input(0)->HasMBLayout() || // <= !Input(0)->HasMBLayout()))) // <= { LogicError(..., NodeName().c_str(),OperationName().c_str()); } .... }
void assignpatch(const ssematrixbase &patch, const size_t i0, const size_t i1, const size_t j0, const size_t j1) { .... for (size_t j = j0; j < j1; j++) { const float *pcol = &patch(i0 - i0, j - j0); // <= float *qcol = &us(i0, j); const size_t colbytes = (i1 - i0) * sizeof(*pcol); memcpy(qcol, pcol, colbytes); } .... }
template <class ElemType> ComputationNetworkPtr SimpleNetworkBuilder<ElemType>:: BuildNetworkFromDbnFile(const std::wstring& dbnModelFileName) { .... if (this->m_outputLayerSize >= 0) outputLayerSize = this->m_outputLayerSize; else if (m_layerSizes.size() > 0) m_layerSizes[m_layerSizes.size() - 1]; else std::runtime_error("Output layer size must be..."); // <= .... }
.... else throw std::runtime_error("Output layer size must be..."); ....
string fgetstring(FILE* f) { string res; for (;;) { char c = (char) fgetc(f); // <= if (c == EOF) // <= RuntimeError("error reading .... 0: %s", strerror(errno)); if (c == 0) break; res.push_back(c); } return res; }
#define EOF (-1)
int c = fgetc(f); if (c == EOF) RuntimeError(....);
bool File::IsUnicodeBOM(bool skip) { .... else if (m_options & fileOptionsText) { char val[3]; file.ReadString(val, 3); found = (val[0] == 0xEF && val[1] == 0xBB && val[2] == 0xBF); } // restore pointer if no BOM or we aren't skipping it if (!found || !skip) { SetPosition(pos); } .... }
template <class ElemType> void SparseBinaryMatrix<ElemType>::ResizeArrays(size_t newNNz) { .... if (m_nnz > 0) { memcpy(rowIndices, m_rowIndices, sizeof(int32_t)....); // <= memcpy(values, this->m_values, sizeof(ElemType)....); // <= } if (m_rowIndices != nullptr) { // free(m_rowIndices); CUDAPageLockedMemAllocator::Free(this->m_rowIndices, ....); } if (this->m_values != nullptr) { // free(this->m_values); CUDAPageLockedMemAllocator::Free(this->m_values, ....); } .... }
const std::wstring& GetName() { return m_name; } Section* Section::ReadSection(....) { .... char message[256]; sprintf_s(message,"Invalid header in file %ls, in header %s\n", m_file->GetName(), section->GetName()); // <= RuntimeError(message); .... }
sprintf_s(message,"Invalid header in file %ls, in header %s\n", m_file->GetName().c_str(), section->GetName().c_str());
void lattice::forwardbackwardalign() { .... aligninfo *refinfo; unsigned short *refalign; refinfo = (aligninfo *) malloc(sizeof(aligninfo) * 1); // <= refalign = (unsigned short *) malloc(sizeof(....) * framenum); array_ref<aligninfo> refunits(refinfo, 1); array_ref<unsigned short> refedgealignmentsj(....); .... }
struct aligninfo // phonetic alignment { unsigned int unit : 19; // triphone index unsigned int frames : 11; // duration in frames unsigned int unused : 1; // (for future use) unsigned int last : 1; // set for last entry aligninfo(size_t punit, size_t pframes) : unit((unsigned int) punit), frames((unsigned int) pframes), unused(0), last(0) { checkoverflow(unit, punit, "aligninfo::unit"); checkoverflow(frames, pframes, "aligninfo::frames"); } aligninfo() // [v-hansu] initialize to impossible values { #ifdef INITIAL_STRANGE unit = unsigned int(-1); frames = unsigned int(-1); unused = unsigned int(-1); last = unsigned int(-1); #endif } template <class IDMAP> void updateunit(const IDMAP& idmap /*[unit] -> new unit*/) { const size_t mappedunit = idmap[unit]; unit = (unsigned int) mappedunit; checkoverflow(unit, mappedunit, "aligninfo::unit"); } };
aligninfo *refinfo = new aligninfo();
IDataWriter<ElemType>* m_dataWriter; .... template <class ElemType> void DataWriter<ElemType>::Destroy() { delete m_dataWriter; // <= V599 warning m_dataWriter = NULL; }
template <class ElemType> class DATAWRITER_API IDataWriter { public: typedef std::string LabelType; typedef unsigned int LabelIdType; virtual void Init(....) = 0; virtual void Init(....) = 0; virtual void Destroy() = 0; virtual void GetSections(....) = 0; virtual bool SaveData(....) = 0; virtual void SaveMapping(....) = 0; };
m_dataWriter = new HTKMLFWriter<ElemType>();
template <class ElemType> class HTKMLFWriter : public IDataWriter<ElemType> { private: std::vector<size_t> outputDims; std::vector<std::vector<std::wstring>> outputFiles; std::vector<size_t> udims; std::map<std::wstring, size_t> outputNameToIdMap; std::map<std::wstring, size_t> outputNameToDimMap; std::map<std::wstring, size_t> outputNameToTypeMap; unsigned int sampPeriod; size_t outputFileIndex; void Save(std::wstring& outputFile, ....); ElemType* m_tempArray; size_t m_tempArraySize; .... };
enum SequenceFlags { seqFlagNull = 0, seqFlagLineBreak = 1, // line break on the parsed line seqFlagEmptyLine = 2, // empty line seqFlagStartLabel = 4, seqFlagStopLabel = 8 }; long Parse(....) { .... // sequence state machine variables bool m_beginSequence; bool m_endSequence; .... if (seqPos) { SequencePosition sequencePos(numbers->size(), labels->size(), m_beginSequence ? seqFlagStartLabel : 0 | m_endSequence ? seqFlagStopLabel : 0 | seqFlagLineBreak); // add a sequence element to the list seqPos->push_back(sequencePos); sequencePositionLast = sequencePos; } // end of sequence determines record separation if (m_endSequence) recordCount = (long) labels->size(); .... }
0 | m_endSequence ? seqFlagStopLabel : 0 | seqFlagLineBreak
// TODO: merge this with todouble(const char*) above static inline double todouble(const std::string& s) { s.size(); // just used to remove the unreferenced warning double value = 0.0; .... }
#define UNREFERENCED_PARAMETER(P) (P) static inline double todouble(const std::string& s) { UNREFERENCED_PARAMETER(s); .... }
template <class UTTREF> std::vector<shiftedvector<....>>getclassids(const UTTREF &uttref) { std::vector<shiftedvector<....>> allclassids; allclassids.empty(); // <= .... }
template <class ElemType> class SequenceReader : public IDataReader<ElemType> { protected: bool m_idx2clsRead; bool m_clsinfoRead; bool m_idx2probRead; std::wstring m_file; // <= .... } template <class ElemType> template <class ConfigRecordType> void SequenceReader<ElemType>::InitFromConfig(....) { .... std::wstring m_file = readerConfig(L"file"); // <= if (m_traceLevel > 0) { fprintf(stderr, "....", m_file.c_str()); } .... }
Source: https://habr.com/ru/post/276427/
All Articles