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

[hts-users:04158] HHEd to process multiple workloads


Hi,



Summary:
I'm trying to modify HHEd to process multiple workloads, while initializing only once. Error "ERROR [+9999]  AssignStructure: incompatible tree" occurs.




Details:

The full original command line looks like the following:

HHEd -A -B -C trn.cnf -D -T 1 -p -i -H cmp.re_clustered.mmf -w cmp.re_clustered_all.mmf.1mix mku.cmp.hed full.list

... where"-w cmp.re_clustered_all.mmf.1mix" and "mku.cmp.hed" are the parameters that define "a workload". The goal is to initialize an instance of HHEd once using the rest of the command line parameters, and then process sequentially multiple sets of the "workloads". Examples of trn.cnf and mku.cmd.hed files are attached.


A simplified version of the source code is attached in HHEdPP.cpp file. HHEd_Init() is called once, and then HHEd_DoWork() is called repeatedly with different parameters. On the second HHEd_DoWork() call, the error "ERROR [+9999]  AssignStructure: incompatible tree" is generated. Apparently, some clean-up must be done after each HHEd_DoWork() call, but I am unable to figure out how to do that correctly.

Any insight into how hset->swidth is initialized and how to clean it up properly for reuse is greatly appreciated!



Regards,
Dmitry.
static char szMmfFileNameBuffer[1024];
static char szEditFnBuffer[1024];
static char szHmmListFnBuffer[1024];

void HHEd_Init(int argc, char *argv[], const char *pszHmmListFn)
{
	char *s, *editFn;

	if (InitShell(argc, argv, hhed_version, hhed_vc_id)<SUCCESS)
		HError(2600, "HHEd: InitShell failed");
	InitMem();
	InitLabel();
	InitMath();
	InitSigP();
	InitWave();
	InitAudio();
	InitVQ();
	InitModel();
	if (InitParm()<SUCCESS)
		HError(2600, "HHEd: InitParm failed");
	InitUtil();
	InitAdapt(&xfInfo, NULL);

	if (!InfoPrinted() && NumArgs() == 0)
		ReportUsage();
	if (NumArgs() == 0)
		HError(0, "HHEd: missing arguments");
	SetConfParms();

	CreateHeap(&hmmHeap, "Model Heap", MSTAK, 1, 1.0, 40000, 1600000);
	CreateHMMSet(&hSet, &hmmHeap, TRUE);
	hset = &hSet;
	fidx = 0;

	while (NextArg() == SWITCHARG) {
		s = GetSwtArg();
		if (strlen(s) != 1)
			HError(2619, "HHEd: Bad switch %s; must be single letter", s);
		switch (s[0]) {
		case 'a':
			MDLfactor = GetChkedFlt(0.0, 100000000.0, s); break;
		case 'd':
			if (NextArg() != STRINGARG)
				HError(2619, "HHEd: Input HMM definition directory expected");
			hmmDir = GetStrArg(TRUE); break;
		case 'i':
			ignoreStrW = TRUE; break;
		case 'm':
			applyMDL = TRUE; break;
		case 'o':
			if (NextArg() != STRINGARG)
				HError(2619, "HHEd: Output HMM file extension expected");
			newExt = GetStrArg(TRUE); break;
		case 'p':
			usePattern = TRUE; break;
		case 'q':
			useRefTree = GetChkedInt(0, 3, s); break;
		case 'r':
			reduceMem = GetChkedInt(0, 2, s); break;
		case 's':
			singleTree = TRUE; break;
		case 'v':
			minVar = GetChkedFlt(0.0, 100.0, s); break;
		case 'w':
			if (NextArg() != STRINGARG)
				HError(2619, "HHEd: Output MMF file name expected");
			mmfFn = GetStrArg(TRUE);
			break;
		case 'x':
			if (NextArg() != STRINGARG)
				HError(2619, "HHEd: Input HMM file extension expected");
			hmmExt = GetStrArg(TRUE); break;
		case 'z':
			noAlias = TRUE; break;
		case 'B':
			inBinary = TRUE; break;
		case 'J':
			if (NextArg() != STRINGARG)
				HError(2319, "HERest: input transform directory expected");
			AddInXFormDir(hset, GetStrArg(TRUE));
			break;
		case 'H':
			if (NextArg() != STRINGARG)
				HError(2619, "HHEd: Input MMF file name expected");
			AddMMF(hset, GetStrArg(TRUE));
			break;
		case 'M':
			if (NextArg() != STRINGARG)
				HError(2619, "HHEd: Output HMM definition directory expected");
			newDir = GetStrArg(TRUE); break;
		case 'Q':
			Summary(); break;
		case 'T':
			trace = cmdTrace = GetChkedInt(0, 0x3FFFF, s); break;
		default:
			HError(2619, "HHEd: Unknown switch %s", s);
		}
	}

	strncpy(szHmmListFnBuffer, pszHmmListFn, sizeof(szHmmListFnBuffer)-1);
	hmmListFn = szHmmListFnBuffer;

	Initialise(hmmListFn);

	if (hset->logWt == TRUE)
		HError(999, "HHEd requires linear weights");
}

void DoEdit1(char *mmfFile, char * editFn)
{
   int prevCommand = 0,c1,c2;
   char cmds[] = "  ";
  
   /* Open the Edit Script File */
   if(InitSource(editFn,&source,NoFilter)<SUCCESS)
      HError(2610,"DoEdit: Can't open file %s", editFn);
      
   /* Apply each Command */
   for (;;) {
      SkipWhiteSpace(&source);
      if( (c1 = GetCh(&source)) == EOF) break;
      if( (c2 = GetCh(&source)) == EOF) break;
      cmds[0] = c1; cmds[1] = c2;
      if (!isspace(GetCh(&source))) 
         HError(2650,"DoEdit: White space expected after command %s",cmds);
      thisCommand = CmdIndex(cmds);
      if ((thisCommand != lastCommand && prevCommand != TR &&
           thisCommand != SH && thisCommand != ST) || thisCommand == TR)
         trace = cmdTrace;
      switch (thisCommand) {
      case AT: EditTransMat(TRUE); break;
      case RT: EditTransMat(FALSE); break;
      case SS: SplitStreamCommand(FALSE); break;
      case CL: CloneCommand(); break;
      case CM: ConvertModelsCommand(); break;
      case CO: CompactCommand(); break;
      case CT: ConvertTreesCommand(); break;
      case JO: JoinSizeCommand(); break;
      case MU: MixUpCommand(); break;
      case MD: MixDownCommand(); break;
      case TI: TieCommand(); break;
      case NC: ClusterCommand(TRUE); break;
      case SM: StateMappingCommand(); break;
      case TC: ClusterCommand(FALSE); break;
      case UT: UntieCommand(); break;
      case MT: MakeTriCommand(); break;
      case SH: ShowHMMSet(); break;
      case SU: SplitStreamCommand(TRUE); break;
      case SW: SetStreamWidthCommand(); break;
      case SK: SetSampKindCommand(); break;
      case HK: SetHSetKindCommand(); break;
      case RC: RegClassesCommand(); break;
      case RM: RemMeansCommand(); break;
      case RN: RenameHMMSetIdCommand(); break;
      case RP: ReOrderFeaturesCommand(); break;
      case RO: RemOutliersCommand(); break;
      case LS: LoadStatsCommand(); break;
      case QS: QuestionCommand(); break;
      case TB: TreeBuildCommand(); break;
      case TR: SetTraceCommand(); break;
      case AU: AddUnseenCommand(); break;
      case ST: ShowTreesCommand(); break;
      case LT: LoadTreesCommand(); break;
      case MM: MakeIntoMacrosCommand(); break;
      case DM: DeleteMacroCommand(); break;
      case DP: DuplicateCommand(); break;
      case IX: InputXFormCommand(); break;
      case PX: ParentXFormCommand(); break;
      case AX: AdaptXFormCommand(); break;
      case UF: UseCommand(); break;
      case FA: FloorAverageCommand(); break;
      case FC: FullCovarCommand(); break;
      case DV: DiagVarCommand(); break;
      case FV: FloorVectorCommand(); break;
      case PS: PowerSizeCommand(); break;
      case PR: ProjectCommand(); break;
      case DR: DecTrees2RegTreeCommand(); break;
      case IT: ImposeTreeCommand (); break;
      case JM: JoinModelCommand(); break;
      case XX: CommentCommand(); break;
      default: 
         HError(2650,"DoEdit: Command %s not recognised",cmds);
      }
      if (thisCommand != TR && thisCommand != SH && thisCommand != ST)
         lastCommand = thisCommand;
      prevCommand = thisCommand;
   }
   CloseSource(&source);
   
   if (saveHMMSet) {
      /* Save the Edited HMM Files */
      if (trace & T_BID) {
         printf("\nSaving new HMM files ...\n");
         fflush(stdout);
      }
      if (badGC) {
      FixAllGConsts(hset);         /* in case any bad gConsts around */
      badGC=FALSE;
      }
      PurgeMacros(hset);

	  if (mmfFn != NULL || mmfFile != NULL)
		  SaveInOneFile(hset, (mmfFn != NULL ? mmfFn : mmfFile));
      if(SaveHMMSet(&hSet,newDir,newExt,NULL,inBinary)<SUCCESS)
         HError(2611,"DoEdit: SaveHMMSet failed");
   }

   if (trace & T_BID) {
      printf("Edit Complete\n");
      fflush(stdout);
   }
}

void HHEd_DoWork(const char *pszMmfFileName, const char *pszEditFn)
{
	strncpy(szMmfFileNameBuffer, pszMmfFileName, sizeof(szMmfFileNameBuffer)-1);
	strncpy(szEditFnBuffer, pszEditFn, sizeof(szEditFnBuffer)-1);

	DoEdit1(szMmfFileNameBuffer, szEditFnBuffer);
}

void HHEd_Destroy()
{
	ResetHeap(&hmmHeap);
	ResetHeap(&tmpHeap);
	ResetHeap(&questHeap);

	ResetAdapt(&xfInfo, NULL);
	ResetUtil();
	ResetParm();
	ResetModel();
	ResetVQ();
	ResetAudio();
	ResetWave();
	ResetSigP();
	ResetMath();
	ResetLabel();
	ResetMem();
	ResetShell();
}

Attachment: trn.cnf
Description: Binary data

Attachment: mku.cmp.hed
Description: Binary data


Follow-Ups
[hts-users:04159] Re: HHEd to process multiple workloads, Xingyu Na