[Subject Prev][Subject Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hts-users:02652] A bug in HAdapt.c


Hi,

I found a bug in HAdapt.c. When we cascade transforms, estimation of output xform can become extremely slow. Please apply the attached patch code.

Best regards,

Heiga ZEN (Byung Ha CHUN)

======================================================================
NOTE: The information in this email and any attachments may be confidential
and/or legally privileged. This message may be read, copied and used only by
the intended recipient. If you are not the intended recipient, please
destroy this message, delete any copies held on your system and notify the
sender immediately.

Toshiba Research Europe Limited, registered in England and Wales (2519556).
Registered Office: 208 Cambridge Science Park, Milton Road, Cambridge
CB4 0GZ, England. Web: http://www.toshiba-europe.com/research/crl
======================================================================


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email ______________________________________________________________________
--- HAdapt.c	2010-11-05 14:06:21.283511000 +0000
+++ HAdapt.c	2010-12-20 06:54:47.177110000 +0000
@@ -1537,24 +1537,22 @@
    Vector covar;
    int i, j, bstart, bsize;
    long bl, nblock;
 
    paac = GetPAAccCache(mp);    
-   if ( paac != NULL ) {
-      /* This needs to be altered so that it does not rely on a non-zero first element */
-      if ( paac->bTriMat[1][1][1] == 0 ) {
+   if (paac==NULL) return;
+   if ((paac->bTriMat!=NULL) && (paac->bVector[1]==0.0) && (svec!=NULL)) {
          nblock = (long)(paac->bTriMat[0]);
 	for (bl=1,bstart=0;bl<=nblock;bl++) {
 	  m = paac->bTriMat[bl];
             bsize = DTriMatSize(m);
 	  for (i=1;i<=bsize;i++) { /* Fill the accumulate stores */
 	    for (j=1; j<=i; j++)
 		m[i][j] = svec[i+bstart] * svec[j+bstart];
 	  }
 	  bstart += bsize;
 	}
-      }
       covar = mp->cov.var;
       for (i=1;i<=vsize;i++) {
          if (mp->ckind==INVDIAGC)
            paac->bVector[i] += Lr * (double) covar[i];
          else
@@ -1613,11 +1611,11 @@
          cnt +=bsize;
       }
    }
 }
 
-void UpdateBaseAccsWithPaac(XFInfo *xfinfo)
+void UpdateBaseAccsWithPaac(XFInfo *xfinfo, const int t)
 {
    int i,j,k,b,bsize;
    long nblock, bl;
    int cnti;
    DTriMat tm, m;
@@ -1626,19 +1624,18 @@
    BaseClass *bclass;
    MixPDF *mp;
    AccCache *paac;
    AdaptXForm *outXForm = xfinfo->outXForm;
 
+   /* store statistics */
+   if (t != xfinfo->baseTriMatTime) {
    bclass = outXForm->bclass;
-
-   for (b=1;b<=bclass->numClasses;b++) {
+      for (b=bclass->numClasses;b>0;b--) {
       mp = ((MixtureElem *)(bclass->ilist[b])->item)->mpdf;
+         paac = ((XFormInfo *)mp->info)->paac;
       ra = GetRegAcc(mp);
-
-      if ( ra->bTriMat != NULL) {
-         for (paac=xfinfo->headac; paac!=NULL; paac=paac->next) { 
-            if ((paac->baseclass==b) && (paac->bVector[1]>0.0)) {
+         if ((ra->bTriMat!=NULL) && (paac->bVector[1]>0.0)) {
             acc = paac->bVector;
                nblock = (long)(ra->bDiagMat[0]);
             for (bl=1,cnti=1;bl<=nblock;bl++) {
               m = paac->bTriMat[bl];
                   bsize = DTriMatSize(m);
@@ -1651,20 +1648,20 @@
             }
           }
         }
       }
    }  
-}
 
-void ResetAccCache(XFInfo *xfinfo)
+void ResetAccCache(XFInfo *xfinfo, const int t)
 {
    AccCache *ac;
  
+   if (t != xfinfo->baseTriMatTime) {
    if (xfinfo->headac != NULL) {
       for (ac=xfinfo->headac; ac!=NULL; ac=ac->next) {
         ZeroDVector(ac->bVector);
-        ZeroBlockTriMat(ac->bTriMat);
+         }
       }
    }
 }
 
 static Boolean XFormModCovar(AdaptXForm *xform)
@@ -1719,12 +1716,12 @@
 
      /* Check to see whether this is the very first frame */
    if (xfinfo->headac==NULL) 
       UpdateBaseAccs(xfinfo,svec,t,regAcc);
      else  {
-      UpdateBaseAccsWithPaac(xfinfo); 
-      ResetAccCache(xfinfo);   
+      UpdateBaseAccsWithPaac(xfinfo,t); 
+      ResetAccCache(xfinfo,t);   
    }
    SetBaseAccsTime(xfinfo,t);
 
    if  (xfinfo->headac==NULL) {    
      for (i=1;i<=vsize;i++) {
@@ -5399,12 +5396,12 @@
 {
    SetBaseAccsTime(xfinfo,-2);
    if (xfinfo->headac==NULL)
       UpdateBaseAccs(xfinfo,NULL,-1,NULL);
    else { 
-      UpdateBaseAccsWithPaac(xfinfo);
-      ResetAccCache(xfinfo);
+      UpdateBaseAccsWithPaac(xfinfo,-1);
+      ResetAccCache(xfinfo,-1);
    }
 }
 
 AdaptXForm *GetMLLRDiagCov(XFInfo *xfinfo, AdaptXForm *xform)
 {
@@ -5448,12 +5445,12 @@
             /* Tidy the statistics of the last frame */
             SetBaseAccsTime(xfinfo,-2);
             if (xfinfo->headac==NULL)
                UpdateBaseAccs(xfinfo,NULL,-1,NULL);
             else { 
-               UpdateBaseAccsWithPaac(xfinfo);
-               ResetAccCache(xfinfo);
+               UpdateBaseAccsWithPaac(xfinfo,-1);
+               ResetAccCache(xfinfo,-1);
             }
             /* Generate the new transform */
             MakeFN(xfinfo->coutspkr,NULL,xfinfo->outXFormExt, newMn);
             xfinfo->outXForm = CreateAdaptXForm(hset, xfinfo, newMn);
             GenAdaptXForm(hset,xfinfo);