summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/features/onnx_feature/onnx_feature_test.cpp22
-rw-r--r--searchlib/src/vespa/searchlib/fef/onnx_model.cpp6
-rw-r--r--searchlib/src/vespa/searchlib/fef/onnx_model.h4
-rw-r--r--searchlib/src/vespa/searchlib/fef/test/indexenvironment.cpp18
-rw-r--r--searchlib/src/vespa/searchlib/fef/test/indexenvironment.h20
5 files changed, 34 insertions, 36 deletions
diff --git a/searchlib/src/tests/features/onnx_feature/onnx_feature_test.cpp b/searchlib/src/tests/features/onnx_feature/onnx_feature_test.cpp
index bf7cbeeb5a2..54b574abbf3 100644
--- a/searchlib/src/tests/features/onnx_feature/onnx_feature_test.cpp
+++ b/searchlib/src/tests/features/onnx_feature/onnx_feature_test.cpp
@@ -61,14 +61,14 @@ struct OnnxFeatureTest : ::testing::Test {
factory.addPrototype(std::make_shared<OnnxBlueprint>("onnx"));
factory.addPrototype(std::make_shared<OnnxBlueprint>("onnxModel"));
}
- ~OnnxFeatureTest() override;
+ ~OnnxFeatureTest();
void add_expr(const vespalib::string &name, const vespalib::string &expr) {
vespalib::string feature_name = expr_feature(name);
vespalib::string expr_name = feature_name + ".rankingScript";
indexEnv.getProperties().add(expr_name, expr);
}
- void add_onnx(OnnxModel model) {
- indexEnv.addOnnxModel(std::move(model));
+ void add_onnx(const OnnxModel &model) {
+ indexEnv.addOnnxModel(model);
}
bool try_compile(const vespalib::string &seed) {
resolver->addSeed(seed);
@@ -84,16 +84,16 @@ struct OnnxFeatureTest : ::testing::Test {
void compile(const vespalib::string &seed) {
ASSERT_TRUE(try_compile(seed));
}
- TensorSpec get(const vespalib::string &feature, uint32_t docid) const {
+ TensorSpec get(const vespalib::string &feature, uint32_t docid) {
auto result = program.get_all_features(false);
for (size_t i = 0; i < result.num_features(); ++i) {
if (result.name_of(i) == feature) {
return TensorSpec::from_value(result.resolve(i).as_object(docid));
}
}
- return {"error"};
+ return TensorSpec("error");
}
- TensorSpec get(uint32_t docid) const {
+ TensorSpec get(uint32_t docid) {
auto result = program.get_seeds(false);
EXPECT_EQ(1u, result.num_features());
return TensorSpec::from_value(result.resolve(0).as_object(docid));
@@ -153,11 +153,11 @@ TEST_F(OnnxFeatureTest, strange_input_and_output_names_are_normalized) {
TEST_F(OnnxFeatureTest, input_features_and_output_names_can_be_specified) {
add_expr("my_first_input", "tensor<float>(a[2]):[10,20]");
add_expr("my_second_input", "tensor<float>(a[2]):[5,10]");
- add_onnx(std::move(OnnxModel("custom_names", strange_names_model)
+ add_onnx(OnnxModel("custom_names", strange_names_model)
.input_feature("input:0", "rankingExpression(my_first_input)")
.input_feature("input/1", "rankingExpression(my_second_input)")
.output_name("foo/bar", "my_first_output")
- .output_name("-baz:0", "my_second_output")));
+ .output_name("-baz:0", "my_second_output"));
compile(onnx_feature("custom_names"));
auto expect_add = TensorSpec("tensor<float>(d0[2])").add({{"d0",0}},15).add({{"d0",1}},30);
auto expect_sub = TensorSpec("tensor<float>(d0[2])").add({{"d0",0}},5).add({{"d0",1}},10);
@@ -169,7 +169,7 @@ TEST_F(OnnxFeatureTest, input_features_and_output_names_can_be_specified) {
TEST_F(OnnxFeatureTest, fragile_model_can_be_evaluated) {
add_expr("in1", "tensor<float>(x[2]):[docid,5]");
add_expr("in2", "tensor<float>(x[2]):[docid,10]");
- add_onnx(std::move(OnnxModel("fragile", fragile_model).dry_run_on_setup(true)));
+ add_onnx(OnnxModel("fragile", fragile_model).dry_run_on_setup(true));
EXPECT_TRUE(try_compile(onnx_feature("fragile")));
EXPECT_EQ(get(1), TensorSpec::from_expr("tensor<float>(d0[2]):[2,15]"));
EXPECT_EQ(get(3), TensorSpec::from_expr("tensor<float>(d0[2]):[6,15]"));
@@ -185,7 +185,7 @@ struct MyIssues : Issue::Handler {
TEST_F(OnnxFeatureTest, broken_model_evaluates_to_all_zeros) {
add_expr("in1", "tensor<float>(x[2]):[docid,5]");
add_expr("in2", "tensor<float>(x[3]):[docid,10,31515]");
- add_onnx(std::move(OnnxModel("fragile", fragile_model).dry_run_on_setup(false)));
+ add_onnx(OnnxModel("fragile", fragile_model).dry_run_on_setup(false));
EXPECT_TRUE(try_compile(onnx_feature("fragile")));
MyIssues my_issues;
EXPECT_EQ(my_issues.list.size(), 0);
@@ -199,7 +199,7 @@ TEST_F(OnnxFeatureTest, broken_model_evaluates_to_all_zeros) {
TEST_F(OnnxFeatureTest, broken_model_fails_with_dry_run) {
add_expr("in1", "tensor<float>(x[2]):[docid,5]");
add_expr("in2", "tensor<float>(x[3]):[docid,10,31515]");
- add_onnx(std::move(OnnxModel("fragile", fragile_model).dry_run_on_setup(true)));
+ add_onnx(OnnxModel("fragile", fragile_model).dry_run_on_setup(true));
EXPECT_FALSE(try_compile(onnx_feature("fragile")));
}
diff --git a/searchlib/src/vespa/searchlib/fef/onnx_model.cpp b/searchlib/src/vespa/searchlib/fef/onnx_model.cpp
index 2e7642887ae..bdb037db78d 100644
--- a/searchlib/src/vespa/searchlib/fef/onnx_model.cpp
+++ b/searchlib/src/vespa/searchlib/fef/onnx_model.cpp
@@ -15,10 +15,6 @@ OnnxModel::OnnxModel(const vespalib::string &name_in,
{
}
-OnnxModel::OnnxModel(OnnxModel &&) noexcept = default;
-OnnxModel & OnnxModel::operator =(OnnxModel &&) noexcept = default;
-OnnxModel::~OnnxModel() = default;
-
OnnxModel &
OnnxModel::input_feature(const vespalib::string &model_input_name, const vespalib::string &input_feature) {
_input_features[model_input_name] = input_feature;
@@ -62,4 +58,6 @@ OnnxModel::operator==(const OnnxModel &rhs) const {
std::tie(rhs._name, rhs._file_path, rhs._input_features, rhs._output_names, rhs._dry_run_on_setup));
}
+OnnxModel::~OnnxModel() = default;
+
}
diff --git a/searchlib/src/vespa/searchlib/fef/onnx_model.h b/searchlib/src/vespa/searchlib/fef/onnx_model.h
index fc5b434b22b..f3fef9caa3e 100644
--- a/searchlib/src/vespa/searchlib/fef/onnx_model.h
+++ b/searchlib/src/vespa/searchlib/fef/onnx_model.h
@@ -24,10 +24,6 @@ private:
public:
OnnxModel(const vespalib::string &name_in,
const vespalib::string &file_path_in);
- OnnxModel(OnnxModel &&) noexcept;
- OnnxModel & operator=(OnnxModel &&) noexcept;
- OnnxModel(const OnnxModel &) = delete;
- OnnxModel & operator =(const OnnxModel &) = delete;
~OnnxModel();
const vespalib::string &name() const { return _name; }
diff --git a/searchlib/src/vespa/searchlib/fef/test/indexenvironment.cpp b/searchlib/src/vespa/searchlib/fef/test/indexenvironment.cpp
index 0665f274e53..daa9054dff2 100644
--- a/searchlib/src/vespa/searchlib/fef/test/indexenvironment.cpp
+++ b/searchlib/src/vespa/searchlib/fef/test/indexenvironment.cpp
@@ -11,7 +11,6 @@ using vespalib::eval::ValueType;
IndexEnvironment::IndexEnvironment() = default;
IndexEnvironment::~IndexEnvironment() = default;
-IndexEnvironment::Constant::~Constant() = default;
const FieldInfo *
IndexEnvironment::getField(uint32_t id) const
@@ -22,9 +21,10 @@ IndexEnvironment::getField(uint32_t id) const
const FieldInfo *
IndexEnvironment::getFieldByName(const string &name) const
{
- for (const auto & field : _fields) {
- if (field.name() == name) {
- return &field;
+ for (std::vector<FieldInfo>::const_iterator it = _fields.begin();
+ it != _fields.end(); ++it) {
+ if (it->name() == name) {
+ return &(*it);
}
}
return nullptr;
@@ -38,7 +38,7 @@ IndexEnvironment::getConstantValue(const vespalib::string &name) const
if (it != _constants.end()) {
return std::make_unique<ConstantRef>(it->second);
} else {
- return {nullptr};
+ return vespalib::eval::ConstantValue::UP(nullptr);
}
}
@@ -47,7 +47,9 @@ IndexEnvironment::addConstantValue(const vespalib::string &name,
vespalib::eval::ValueType type,
std::unique_ptr<vespalib::eval::Value> value)
{
- auto insertRes = _constants.emplace(name, Constant(std::move(type), std::move(value)));
+ auto insertRes = _constants.emplace(name,
+ Constant(std::move(type),
+ std::move(value)));
assert(insertRes.second); // successful insert
(void) insertRes;
}
@@ -79,9 +81,9 @@ IndexEnvironment::getOnnxModel(const vespalib::string &name) const
}
void
-IndexEnvironment::addOnnxModel(OnnxModel model)
+IndexEnvironment::addOnnxModel(const OnnxModel &model)
{
- _models.insert_or_assign(model.name(), std::move(model));
+ _models.insert_or_assign(model.name(), model);
}
diff --git a/searchlib/src/vespa/searchlib/fef/test/indexenvironment.h b/searchlib/src/vespa/searchlib/fef/test/indexenvironment.h
index cb14a7cdaea..f204dd06aed 100644
--- a/searchlib/src/vespa/searchlib/fef/test/indexenvironment.h
+++ b/searchlib/src/vespa/searchlib/fef/test/indexenvironment.h
@@ -24,27 +24,27 @@ public:
vespalib::eval::ValueType _type;
std::unique_ptr<vespalib::eval::Value> _value;
Constant(vespalib::eval::ValueType type,
- std::unique_ptr<vespalib::eval::Value> value)
+ std::unique_ptr<vespalib::eval::Value> value)
: _type(std::move(type)), _value(std::move(value))
{ }
- Constant(Constant &&rhs) noexcept
+ Constant(Constant &&rhs)
: _type(std::move(rhs._type)),
_value(std::move(rhs._value))
{
}
const vespalib::eval::ValueType &type() const override { return _type; }
const vespalib::eval::Value &value() const override { return *_value; }
- ~Constant() override;
+ ~Constant() { }
};
struct ConstantRef : vespalib::eval::ConstantValue {
const Constant &_value;
- explicit ConstantRef(const Constant &value)
+ ConstantRef(const Constant &value)
: _value(value)
{ }
const vespalib::eval::ValueType &type() const override { return _value.type(); }
const vespalib::eval::Value &value() const override { return _value.value(); }
- ~ConstantRef() override = default;
+ ~ConstantRef() { }
};
using ConstantsMap = std::map<vespalib::string, Constant>;
@@ -52,9 +52,7 @@ public:
using ModelMap = std::map<vespalib::string, OnnxModel>;
IndexEnvironment();
- IndexEnvironment(const IndexEnvironment &) = delete;
- IndexEnvironment & operator=(const IndexEnvironment &) = delete;
- ~IndexEnvironment() override;
+ ~IndexEnvironment();
const Properties &getProperties() const override { return _properties; }
uint32_t getNumFields() const override { return _fields.size(); }
@@ -92,7 +90,11 @@ public:
void addRankingExpression(const vespalib::string &name, const vespalib::string &value);
const OnnxModel *getOnnxModel(const vespalib::string &name) const override;
- void addOnnxModel(OnnxModel model);
+ void addOnnxModel(const OnnxModel &model);
+
+private:
+ IndexEnvironment(const IndexEnvironment &); // hide
+ IndexEnvironment & operator=(const IndexEnvironment &); // hide
private:
Properties _properties;