/// <summary> /// The example shows /// - how to evaluate multiple sample requests in parallel. /// Note: The example uses the model trained by <CNTK>/Examples/Image/Classification/ResNet/Python/TrainResNet_CIFAR10.py /// Please see README.md in <CNTK>/Examples/Image/Classification/ResNet about how to train the model. /// The parameter 'modelFile' specifies the path to the model. /// </summary> void ParallelEvaluationExample(const wchar_t* modelFile, const DeviceDescriptor& device) { printf("\n===== Evaluate multiple requests in parallel.\n"); size_t threadCount = 3; // Load the model. // The model is trained by <CNTK>/Examples/Image/Classification/ResNet/Python/TrainResNet_CIFAR10.py // Please see README.md in <CNTK>/Examples/Image/Classification/ResNet about how to train the model. FunctionPtr modelFunc = Function::Load(modelFile, device); // Run evaluation in parallel. std::vector<std::thread> threadList(threadCount); for (int th = 0; th < threadCount; ++th) { threadList[th] = std::thread(RunEvaluationOnSingleSample, modelFunc->Clone(ParameterCloningMethod::Share), device); } for (int th = 0; th < threadCount; ++th) { threadList[th].join(); printf("thread %d joined.\n", th); } }