Use select ternary op in tensor select evaulator
Reference issue
What does this implement/fix?
If the select expression is compatible with scalar_boolean_select_op
, use that instead. Otherwise, fall back to the current (partially) vectorized implementation. This only affects the packet
function -- everything else is unmodified.
int main()
{
using TypedGTOp = internal::scalar_cmp_op<float, float, internal::cmp_GT, true>;
Index i_size = 2000, j_size = 300, k_size = 1000;
Tensor<float, 3> selector(i_size, j_size, k_size);
Tensor<float, 3> mat1(i_size, j_size, k_size);
Tensor<float, 3> mat2(i_size, j_size, k_size);
Tensor<float, 3> result(i_size, j_size, k_size);
selector.setRandom();
mat1.setRandom();
mat2.setRandom();
result = (selector > mat1).select(mat1, mat2); // current boolean path
result = selector.binaryExpr(mat1, TypedGTOp()).select(mat1, mat2); // new typed path
}
Benchmarks (ms):
Boolean Comparison | Typed Comparison | Diff |
---|---|---|
3,664 | 3,176 | -13% |
Additional information
Edited by Charles Schlosser