4 #include <c10/util/ArrayRef.h> 17 template<
typename F,
typename T>
18 inline auto fmap(
const T& inputs,
const F& fn) -> std::vector<decltype(fn(*inputs.begin()))> {
19 std::vector<decltype(fn(*inputs.begin()))> r;
20 r.reserve(inputs.size());
21 for(
const auto & input : inputs)
22 r.push_back(fn(input));
26 template<
typename F,
typename T>
27 inline auto fmap(
T& inputs,
const F& fn) -> std::vector<decltype(fn(*inputs.begin()))> {
28 std::vector<decltype(fn(*inputs.begin()))> r;
29 r.reserve(inputs.size());
30 for(
auto & input : inputs)
31 r.push_back(fn(input));
37 template<
typename R,
typename T>
38 inline std::vector<R> fmap(
const T& inputs) {
40 r.reserve(inputs.size());
41 for(
auto & input : inputs)
42 r.push_back(R(input));
46 template<
typename F,
typename T>
49 r.reserve(inputs.
size());
50 for(
auto & input : inputs) {
58 template<
typename F,
typename T>
59 inline std::vector<T> filter(
const std::vector<T>& inputs,
const F& fn) {
constexpr size_t size() const
size - Get the array size.
To register your own kernel for an operator, do in one (!) cpp file: C10_REGISTER_KERNEL(OperatorHand...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...