| 79 | } |
| 80 | |
| 81 | std::pair<float, float> FindMinMax(ITensorHandle* tensorHandle) |
| 82 | { |
| 83 | auto tensor_data = static_cast<const float *>(tensorHandle->Map(true)); |
| 84 | auto tensor_size = tensorHandle->GetShape().GetNumElements(); |
| 85 | |
| 86 | // Set min/max initially to first value in tensor |
| 87 | float min = tensor_data[0]; |
| 88 | float max = tensor_data[0]; |
| 89 | |
| 90 | // Loop over rest of tensor and update min/max if necessary |
| 91 | for (unsigned int val = 1; val < tensor_size; val++) |
| 92 | { |
| 93 | if (tensor_data[val] < min) |
| 94 | { |
| 95 | min = tensor_data[val]; |
| 96 | } |
| 97 | else if (tensor_data[val] > max) |
| 98 | { |
| 99 | max = tensor_data[val]; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | tensorHandle->Unmap(); |
| 104 | |
| 105 | return std::make_pair(min, max); |
| 106 | } |
| 107 | |
| 108 | TensorShape ReduceDims(const TensorShape& tensorShape, unsigned int dimensions) |
| 109 | { |
nothing calls this directly
no test coverage detected