'When to use Map and when element-wise ops?
I'm comparing XLA's xla::Map and element-wise ops, and I'd like to work out when to use each.
API
On a quick glance, it appears that all computations on scalars can also be defined for arbitrary shapes since all relevant ops have element-wise variants (Eq, Sin, Add etc.). I'm not clear what Map provides other than an alternative API. Or is it simply so that we can use a pre-built scalar computation, in which case how does it differ from Call?
Performance
Does xla::Map have the same performance characteristics as element-wise ops? That is, in pseudo-code, are
Map(x, Abs)
Map(x, compose(Neg, Abs))
Map({x, y}, Eq)
optimised at least approximately as efficiently as
Abs(x)
Neg(Abs(x))
Eq(x, y)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
