blob: 5b61eaec085bd286ba5975c92d3dcecebf8576f9 (
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
32
33
34
35
36
37
38
|
// 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 combining multiple vector-based similarity measures
* to find the best one. This function supports the following cases:
*
* - maximum dot product of vectors with float cell type (MaxSim)
* - minimum hamming distance of bitvectors with int8 cell type
*
* The vectors used to calculate the individual distance metrics must
* be the inner dense dimension of both inputs. The dimension reduced
* to find the best similarity measure must be the remaining dimension
* of one of the inputs.
**/
class BestSimilarityFunction : public tensor_function::Op2
{
private:
InterpretedFunction::op_function _my_fun;
size_t _inner_size;
uint64_t make_param(Stash &stash) const;
public:
BestSimilarityFunction(const ValueType &res_type_in,
const TensorFunction &pri,
const TensorFunction &sec,
InterpretedFunction::op_function my_fun,
size_t inner_size);
InterpretedFunction::Instruction compile_self(const ValueBuilderFactory &factory, Stash &stash) const override;
bool result_is_mutable() const override { return true; }
static const TensorFunction &optimize(const TensorFunction &expr, Stash &stash);
};
} // namespace
|