static void DoLblReloc( back_handle bck, int disp ){ /**********************************/ type_def *ptr_type; segment_id id; id = AskSegID( bck, CG_BACK ); ptr_type = TypeAddress( TY_NEAR_POINTER ); BackPtr( bck, id, disp, ptr_type ); }
static void LabelReloc( segment_id segid, back_handle bck, offset disp ) /**********************************************************************/ { type_def *ptr_type; segment_id bck_segid; segment_id old_segid; old_segid = SetOP( segid ); bck_segid = AskSegID( bck, CG_BACK ); ptr_type = TypeAddress( TY_LONG_POINTER ); BackPtr( bck, bck_segid, disp, ptr_type ); SetOP( old_segid ); }
void SeqModel::tryUpdate(Dtw_Column_Link * link, int columnIdx, int preStateID, int stateID, double newCost) { int rollIdx = getRollIdx(columnIdx); int preIdx = rollIdx ^ 1; Dtw_Column_Node & dtw_node = link[rollIdx].nodes[stateID]; // printf("ddx %d %d %lf\n", preStateID, stateID, newCost); /* if(!(newCost>= 0) && !(newCost<= 0)) { printf("%lf\n", newCost); printf("%d %d\n", preStateID, stateID); getchar(); } */ bool updateFlag = false; // new node!! if(dtw_node.lastUpdate != columnIdx) { link[rollIdx].addColumnNode( stateID ); dtw_node.lastUpdate = columnIdx; // new nodes' backPtr should be inited to -1 // This complex logic.. is a tradeoff for high efficiency beam search dtw_node.preIdx = NIL_BACK_PTR; updateFlag = true; } else if(Feature::better(newCost, dtw_node.cost)) updateFlag = true; if(updateFlag) { // printf("new \n"); // if(newCost > Feature::IllegalDist) dtw_node.cost = newCost; // record path if(path_type == FULL_PATH) { // bug 如果从一个nonemit 过来的, 则path指向nonemit指向的单词就可以了 // 虽然nonemit到nonemit是同一个列之间的forward,但编码时候是从前一列 // forward过来的,这样可以避免用新的值更新 // // while(preStateID >= 0 && ! isEmit(preStateID) ) // preStateID = link[preIdx].nodes[preStateID].preIdx; fullPath[columnIdx][stateID] = preStateID; dtw_node.preIdx = preStateID; } else if(path_type == BACK_PTR) { if(isEmit(preStateID) && isEmit(stateID)) { dtw_node.preIdx = link[preIdx].nodes[preStateID].preIdx; } else if(!isEmit(preStateID) && !isEmit(stateID) ) { // printf("%d %d\n", preStateID, stateID); // preIdx !! it is a trans inner a t, however i copy old value to preIdx. dtw_node.preIdx = link[preIdx].nodes[preStateID].preIdx; } else if(!isEmit(preStateID) && isEmit(stateID) ) { dtw_node.preIdx = link[preIdx].nodes[preStateID].preIdx; } else if(isEmit(preStateID) && ! isEmit(stateID) ) { // new back ptr // should be forwarding // same column, same rollIdx , forwarding if(dtw_node.preIdx == NIL_BACK_PTR) { backPtrs.push_back( BackPtr() ); dtw_node.preIdx = backPtrs.size() - 1; } backPtrs[dtw_node.preIdx].word = states[preStateID].word; backPtrs[dtw_node.preIdx].prePtr = link[rollIdx].nodes[preStateID].preIdx; //dtw_node.preIdx; backPtrs[dtw_node.preIdx].stateID = stateID; } } /* if(!(newCost>= 0) && !(newCost<= 0)) { printf("Star %lf %lf %lf\n", 1.0, states[stateID].forwardCost, newCost); getchar(); } */ tryForwardToStar( link, columnIdx, stateID, newCost ); } }