Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0.X] L2TauTagNNProducerAlpaka: do not call TF inference with empty grid #45148

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions RecoTauTag/HLTProducers/src/L2TauTagNNProducerAlpaka.cc
Original file line number Diff line number Diff line change
Expand Up @@ -731,15 +731,19 @@ void L2TauNNProducerAlpaka::fillPatatracks(tensorflow::Tensor& cellGridMatrix,
}

std::vector<float> L2TauNNProducerAlpaka::getTauScore(const tensorflow::Tensor& cellGridMatrix) {
std::vector<tensorflow::Tensor> pred_tensor;
tensorflow::run(L2cacheData_->session, {{inputTensorName_, cellGridMatrix}}, {outputTensorName_}, &pred_tensor);
const int nTau = cellGridMatrix.shape().dim_size(0);
std::vector<float> pred_vector(nTau);
for (int tau_idx = 0; tau_idx < nTau; ++tau_idx) {
pred_vector[tau_idx] = pred_tensor[0].matrix<float>()(tau_idx, 0);
}
if (nTau == 0) {
return std::vector<float>();
} else {
std::vector<tensorflow::Tensor> pred_tensor;
tensorflow::run(L2cacheData_->session, {{inputTensorName_, cellGridMatrix}}, {outputTensorName_}, &pred_tensor);
std::vector<float> pred_vector(nTau);
for (int tau_idx = 0; tau_idx < nTau; ++tau_idx) {
pred_vector[tau_idx] = pred_tensor[0].matrix<float>()(tau_idx, 0);
}

return pred_vector;
return pred_vector;
}
}

void L2TauNNProducerAlpaka::produce(edm::Event& event, const edm::EventSetup& eventsetup) {
Expand Down