本文整理汇总了C++中IndexVector::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ IndexVector::push_back方法的具体用法?C++ IndexVector::push_back怎么用?C++ IndexVector::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IndexVector
的用法示例。
在下文中一共展示了IndexVector::push_back方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setBaseLine
void RemoveUnusedStructField::setBaseLine(const RecordDecl *RD,
const FieldDecl *FD)
{
TheRecordDecl = RD;
TheFieldDecl = FD;
IndexVector *IdxVec = new IndexVector();
unsigned int Idx = FD->getFieldIndex();
IdxVec->push_back(Idx);
RecordDeclToField[RD] = IdxVec;
FieldToIdxVector[FD] = IdxVec;
// IsLastField = (FD->getNextDeclInContext() == NULL);
RecordDecl::field_iterator I = RD->field_begin();
IsFirstField = (FD == (*I));
RecordDecl::field_iterator E = RD->field_end();
for (; I != E; ++I) {
NumFields++;
}
}
示例2: verifyUpdateSequenceRaceConditions
// returns the number of race conditions detected (0 or 1 as of now)
int Specialization::verifyUpdateSequenceRaceConditions(LoopInfoSet& loopInfoSet, ArrayUpdatesSequence& arrayUpdates, VariableIdMapping* variableIdMapping) {
int cnt=0;
stringstream ss;
cout<<"STATUS: checking race conditions."<<endl;
cout<<"INFO: number of parallel loops: "<<numParLoops(loopInfoSet,variableIdMapping)<<endl;
VariableIdSet allIterVars;
for(LoopInfoSet::iterator lis=loopInfoSet.begin();lis!=loopInfoSet.end();++lis) {
allIterVars.insert((*lis).iterationVarId);
}
for(LoopInfoSet::iterator lis=loopInfoSet.begin();lis!=loopInfoSet.end();++lis) {
if((*lis).iterationVarType==ITERVAR_PAR) {
VariableId parVariable;
parVariable=(*lis).iterationVarId;
cout<<"INFO: checking parallel loop: "<<variableIdMapping->variableName(parVariable)<<endl;
// race check
// intersect w-set_i = empty
// w-set_i intersect r-set_j = empty, i!=j.
IndexToReadWriteDataMap indexToReadWriteDataMap;
for(ArrayUpdatesSequence::iterator i=arrayUpdates.begin();i!=arrayUpdates.end();++i) {
const EState* estate=(*i).first;
const PState* pstate=estate->pstate();
SgExpression* exp=(*i).second;
IndexVector index;
// use all vars for indexing or only outer+par loop variables
#ifdef USE_ALL_ITER_VARS
for(VariableIdSet::iterator ol=allIterVars.begin();ol!=allIterVars.end();++ol) {
VariableId otherVarId=*ol;
ROSE_ASSERT(otherVarId.isValid());
if(!pstate->varValue(otherVarId).isTop()) {
int otherIntVal=pstate->varValue(otherVarId).getIntValue();
index.push_back(otherIntVal);
}
}
#else
for(VariableIdSet::iterator ol=(*lis).outerLoopsVarIds.begin();ol!=(*lis).outerLoopsVarIds.end();++ol) {
VariableId otherVarId=*ol;
ROSE_ASSERT(otherVarId.isValid());
if(!pstate->varValue(otherVarId).isTop()&&pstate->varValue(otherVarId).isConstInt()) {
int otherIntVal=pstate->varValue(otherVarId).getIntValue();
index.push_back(otherIntVal);
}
}
if(!pstate->varValue(parVariable).isTop()&&pstate->varValue(parVariable).isConstInt()) {
int parIntVal=pstate->varValue(parVariable).getIntValue();
index.push_back(parIntVal);
}
#endif
if((*lis).isInAssociatedLoop(estate)) {
SgExpression* lhs=isSgExpression(SgNodeHelper::getLhs(exp));
SgExpression* rhs=isSgExpression(SgNodeHelper::getRhs(exp));
ROSE_ASSERT(isSgPntrArrRefExp(lhs)||SgNodeHelper::isFloatingPointAssignment(exp));
//cout<<"EXP: "<<exp->unparseToString()<<", lhs:"<<lhs->unparseToString()<<" :: "<<endl;
// read-set
RoseAst rhsast(rhs);
for(RoseAst::iterator j=rhsast.begin();j!=rhsast.end();++j) {
if(SgPntrArrRefExp* useRef=isSgPntrArrRefExp(*j)) {
j.skipChildrenOnForward();
ArrayElementAccessData access(useRef,variableIdMapping);
indexToReadWriteDataMap[index].readArrayAccessSet.insert(access);
} else if(SgVarRefExp* useRef=isSgVarRefExp(*j)) {
ROSE_ASSERT(useRef);
j.skipChildrenOnForward();
VariableId varId=variableIdMapping->variableId(useRef);
indexToReadWriteDataMap[index].readVarIdSet.insert(varId);
} else {
//cout<<"INFO: UpdateExtraction: ignored expression on rhs:"<<(*j)->unparseToString()<<endl;
}
}
if(SgPntrArrRefExp* arr=isSgPntrArrRefExp(lhs)) {
ArrayElementAccessData access(arr,variableIdMapping);
indexToReadWriteDataMap[index].writeArrayAccessSet.insert(access);
} else if(SgVarRefExp* var=isSgVarRefExp(lhs)) {
VariableId varId=variableIdMapping->variableId(var);
indexToReadWriteDataMap[index].writeVarIdSet.insert(varId);
} else {
cerr<<"Error: SSA Numbering: unknown LHS."<<endl;
exit(1);
}
ss<<"UPD"<<cnt<<":"<<pstate->toString(variableIdMapping)<<" : "<<exp->unparseToString()<<endl;
++cnt;
}
} // array sequence iter
// to be utilized later for more detailed output
#if 0
for(IndexToReadWriteDataMap::iterator imap=indexToReadWriteDataMap.begin();
imap!=indexToReadWriteDataMap.end();
++imap) {
// cout<<"DEBUG: INDEX: "<<(*imap).first<<" R-SET: ";
IndexVector index=(*imap).first;
cout<<"DEBUG: INDEX: ";
for(IndexVector::iterator iv=index.begin();iv!=index.end();++iv) {
if(iv!=index.begin())
//.........这里部分代码省略.........
示例3: expandLabels
static void expandLabels(Bundle& bundle, size_t beamSize)
{
auto& outputActivationsVector = bundle["outputActivations"].get<MatrixVector>();
auto& outputActivations = outputActivationsVector.back();
auto& labels = bundle["referenceLabels"].get<LabelVector>();
auto& inputTimesteps = bundle["inputTimesteps"].get<IndexVector>();
size_t characters = outputActivations.size().front();
size_t miniBatchSize = outputActivations.size()[outputActivations.size().size() - 2];
size_t maxTimesteps = outputActivations.size()[outputActivations.size().size() - 1];
size_t originalMiniBatchSize = miniBatchSize / beamSize;
LabelVector expandedLabels;
IndexVector expandedTimesteps;
for(size_t miniBatch = 0; miniBatch < originalMiniBatchSize; ++miniBatch)
{
for(size_t beam = 0; beam < beamSize; ++beam)
{
expandedLabels.push_back(labels[miniBatch]);
expandedTimesteps.push_back(inputTimesteps[miniBatch]);
}
}
labels = std::move(expandedLabels);
inputTimesteps = std::move(expandedTimesteps);
auto referenceActivations = matrix::zeros({characters, miniBatchSize, maxTimesteps},
outputActivations.precision());
for(size_t miniBatch = 0; miniBatch < miniBatchSize; ++miniBatch)
{
for(size_t timestep = 0; timestep < maxTimesteps; ++timestep)
{
if(timestep < labels[miniBatch].size())
{
size_t character = labels[miniBatch][timestep];
assert(character < characters);
referenceActivations(character, miniBatch, timestep) = 1.0;
}
else
{
referenceActivations(characters - 1, miniBatch, timestep) = 1.0;
}
}
}
if(util::isLogEnabled("CTCDecoderLayer::Detail"))
{
util::log("CTCDecoderLayer::Detail") << " reference labels: \n";
for(auto& label : labels)
{
util::log("CTCDecoderLayer::Detail") << " reference label: "
<< util::toString(label) << "\n";
}
util::log("CTCDecoderLayer::Detail") << " reference activations: "
<< referenceActivations.debugString();
}
else
{
util::log("CTCDecoderLayer::Detail") << " reference labels size: "
<< labels.size() << "\n";
util::log("CTCDecoderLayer") << " reference activations size: "
<< outputActivations.shapeString() << "\n";
}
bundle["referenceActivations"] = MatrixVector({referenceActivations});
}