@@ -303,13 +303,31 @@ void initDataLayer(TestConfig testConf,
303303 ICpuGpuVectorPtr sequenceStartPositions;
304304 ICpuGpuVectorPtr subSequenceStartPositions;
305305 IVectorPtr cpuSequenceDims;
306- for (size_t i = 0 ; i < testConf.inputDefs .size (); i++) {
306+ for (size_t i = 0 ; i < testConf.inputDefs .size (); ++i) {
307+ if (testConf.inputDefs [i].inputType != INPUT_SEQUENCE_LABEL) continue ;
308+
309+ const std::vector<int >& labelSeqStartPositions =
310+ testConf.inputDefs [i].labelSeqStartPositions ;
311+ if (labelSeqStartPositions.size () != 0 ) {
312+ CHECK (!sequenceStartPositions);
313+ CHECK_GE (labelSeqStartPositions.size (), 2 );
314+
315+ sequenceStartPositions =
316+ ICpuGpuVector::create (labelSeqStartPositions.size (), useGpu);
317+ sequenceStartPositions->copyFrom (
318+ labelSeqStartPositions.data (), labelSeqStartPositions.size (), useGpu);
319+ }
320+ }
321+
322+ for (size_t i = 0 ; i < testConf.inputDefs .size (); ++i) {
307323 LayerConfig config;
308324 config.set_name (testConf.inputDefs [i].name );
309325 config.set_type (" data" );
310326 config.set_size (testConf.inputDefs [i].dim );
311327 LayerPtr layer = LayerPtr (new DataLayer (config));
312- size_t numSequence = batchSize / 10 + 1 ;
328+ size_t numSequence = sequenceStartPositions
329+ ? sequenceStartPositions->getSize () - 1
330+ : batchSize / 10 + 1 ;
313331
314332 Argument data;
315333 auto fillData = [&](bool trans, int height, int width) {
@@ -336,9 +354,17 @@ void initDataLayer(TestConfig testConf,
336354 break ;
337355 case INPUT_LABEL:
338356 case INPUT_SEQUENCE_LABEL:
339- data.ids = VectorT<int >::create (batchSize, useGpu);
340- // now rand number can be 0 to inputDefs[i].dim
341- data.ids ->rand (testConf.inputDefs [i].dim );
357+ if (testConf.inputDefs [i].labelInitValue .size () != 0 ) {
358+ const std::vector<int >& labelInitValue =
359+ testConf.inputDefs [i].labelInitValue ;
360+ CHECK_EQ (labelInitValue.size (), batchSize);
361+ data.ids = VectorT<int >::create (batchSize, useGpu);
362+ data.ids ->copyFrom (labelInitValue.data (), batchSize);
363+ } else {
364+ data.ids = VectorT<int >::create (batchSize, useGpu);
365+ // now rand number can be 0 to inputDefs[i].dim
366+ data.ids ->rand (testConf.inputDefs [i].dim );
367+ }
342368 break ;
343369 case INPUT_SPARSE_NON_VALUE_DATA:
344370 data.value = makeRandomSparseMatrix (
0 commit comments