Map and filter fusion
This patch introduces MapAndFilterFusion optimization, e.g:
map(map_fun).filter(filter_fun)
It moves computation of filter_fun to the map_fun, which returns the computed element and computed predicate. Filter is replaced with FilterByLastComponentDataset, which
filters by the boolean, resulting in:
map(fused_fun).FilterByLastComponent()
where:
fused_fun(x):
r = map_function(x)
return (r, filter_fun(r))
The micro benchmark shows around 68% improvement (chain of 50 map-filter)
PiperOrigin-RevId: 207624667
Loading
Please sign in to comment