aboutsummaryrefslogtreecommitdiffstats
path: root/eval/src/vespa/eval/instruction/universal_dot_product.h
blob: 2572ab47c659256e97dc0181db91d1d78568f84c (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
// 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 performing dot product compatible operations
 * (join:mul, reduce:sum) on values of arbitrary complexity.
 * 
 * Note: can evaluate 'anything', but unless 'force' is given; will
 * try to be a bit conservative about when to optimize.
 **/
class UniversalDotProduct : public tensor_function::Op2
{
public:
    UniversalDotProduct(const ValueType &res_type, const TensorFunction &lhs, const TensorFunction &rhs);
    InterpretedFunction::Instruction compile_self(const ValueBuilderFactory &factory, Stash &stash) const override;
    bool result_is_mutable() const override { return true; }
    bool forward() const;
    bool distinct() const;
    bool single() const;
    static const TensorFunction &optimize(const TensorFunction &expr, Stash &stash, bool force);
};

} // namespace