aboutsummaryrefslogtreecommitdiffstats
path: root/eval/src/vespa/eval/instruction/dense_lambda_peek_function.h
blob: f61fb71dd8862719819876f388df98945f3b634a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/eval/eval/tensor_function.h>

namespace vespalib::eval {

/**
 * Tensor function creating a new dense tensor based on peeking cells
 * of a single existing dense tensor. Which cells to peek is described
 * by a single (compilable) function mapping the individual dimension
 * indexes of the tensor to be created into global cell indexes of the
 * tensor to be peeked.
 **/
class DenseLambdaPeekFunction : public tensor_function::Op1
{
private:
    std::shared_ptr<Function const> _idx_fun;

public:
    DenseLambdaPeekFunction(const ValueType &result_type,
                            const TensorFunction &child,
                            std::shared_ptr<Function const> idx_fun);
    ~DenseLambdaPeekFunction() override;
    InterpretedFunction::Instruction compile_self(const ValueBuilderFactory &factory, Stash &stash) const override;
    vespalib::string idx_fun_dump() const;
    bool result_is_mutable() const override { return true; }
};

} // namespace