aboutsummaryrefslogtreecommitdiffstats
path: root/eval/src/vespa/eval/instruction/sparse_singledim_lookup.h
blob: ed2e7e1ea3f556cb5314386ed6c51a6bbda1f6e4 (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
// Copyright Vespa.ai. 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 {

/**
 * Look up the result of an expression (double->int64_t->label_enum)
 * in a sparse tensor with a single dimension, resulting in a double
 * result. If lookup keys are kept small [0,10000000> (to avoid label
 * enumeration) this is a simple hashtable lookup with numeric keys.
 **/
class SparseSingledimLookup : public tensor_function::Op2
{
public:
    SparseSingledimLookup(const TensorFunction &tensor, const TensorFunction &expr);
    InterpretedFunction::Instruction compile_self(const CTFContext &ctx) const override;
    bool result_is_mutable() const override { return true; }
    static const TensorFunction &optimize(const TensorFunction &expr, Stash &stash);
};

} // namespace