diff options
author | Arne Juul <arnej@verizonmedia.com> | 2020-12-04 13:06:53 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2020-12-06 20:59:45 +0100 |
commit | c9785734e2bf04e063cb693a54f6d769a1a83704 (patch) | |
tree | e411bd87ad982cbe72e8bc1a94279fcce07e187a /eval | |
parent | 6ecf2793233d3fa44fa6316e27be2220dce883ab (diff) |
untangle ONNX integration from old DenseTensor
Diffstat (limited to 'eval')
-rw-r--r-- | eval/src/tests/tensor/onnx_wrapper/onnx_wrapper_test.cpp | 15 | ||||
-rw-r--r-- | eval/src/vespa/eval/tensor/dense/onnx_wrapper.cpp | 5 | ||||
-rw-r--r-- | eval/src/vespa/eval/tensor/dense/onnx_wrapper.h | 2 |
3 files changed, 11 insertions, 11 deletions
diff --git a/eval/src/tests/tensor/onnx_wrapper/onnx_wrapper_test.cpp b/eval/src/tests/tensor/onnx_wrapper/onnx_wrapper_test.cpp index 3cd7f697067..0f125717d47 100644 --- a/eval/src/tests/tensor/onnx_wrapper/onnx_wrapper_test.cpp +++ b/eval/src/tests/tensor/onnx_wrapper/onnx_wrapper_test.cpp @@ -1,8 +1,7 @@ // Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <vespa/eval/eval/tensor_spec.h> #include <vespa/eval/tensor/dense/onnx_wrapper.h> -#include <vespa/eval/tensor/dense/dense_tensor_view.h> -#include <vespa/eval/tensor/dense/mutable_dense_tensor_view.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/gtest/gtest.h> @@ -165,13 +164,13 @@ TEST(OnnxTest, simple_onnx_model_can_be_evaluated) auto cells = output.cells(); EXPECT_EQ(cells.type, CellType::FLOAT); EXPECT_EQ(cells.size, 1); - EXPECT_EQ(GetCell::from(cells, 0), 79.0); + EXPECT_EQ(cells.typify<float>()[0], 79.0); //------------------------------------------------------------------------- std::vector<float> new_bias_values({10.0}); DenseValueView new_bias(bias_type, TypedCells(new_bias_values)); ctx.bind_param(2, new_bias); ctx.eval(); - EXPECT_EQ(GetCell::from(output.cells(), 0), 80.0); + EXPECT_EQ(output.cells().typify<float>()[0], 80.0); //------------------------------------------------------------------------- } @@ -211,13 +210,13 @@ TEST(OnnxTest, dynamic_onnx_model_can_be_evaluated) auto cells = output.cells(); EXPECT_EQ(cells.type, CellType::FLOAT); EXPECT_EQ(cells.size, 1); - EXPECT_EQ(GetCell::from(cells, 0), 79.0); + EXPECT_EQ(cells.typify<float>()[0], 79.0); //------------------------------------------------------------------------- std::vector<float> new_bias_values({5.0,6.0}); DenseValueView new_bias(bias_type, TypedCells(new_bias_values)); ctx.bind_param(2, new_bias); ctx.eval(); - EXPECT_EQ(GetCell::from(output.cells(), 0), 81.0); + EXPECT_EQ(output.cells().typify<float>()[0], 81.0); //------------------------------------------------------------------------- } @@ -257,13 +256,13 @@ TEST(OnnxTest, int_types_onnx_model_can_be_evaluated) auto cells = output.cells(); EXPECT_EQ(cells.type, CellType::DOUBLE); EXPECT_EQ(cells.size, 1); - EXPECT_EQ(GetCell::from(cells, 0), 79.0); + EXPECT_EQ(cells.typify<double>()[0], 79.0); //------------------------------------------------------------------------- std::vector<double> new_bias_values({10.0}); DenseValueView new_bias(bias_type, TypedCells(new_bias_values)); ctx.bind_param(2, new_bias); ctx.eval(); - EXPECT_EQ(GetCell::from(output.cells(), 0), 80.0); + EXPECT_EQ(output.cells().typify<double>()[0], 80.0); //------------------------------------------------------------------------- } diff --git a/eval/src/vespa/eval/tensor/dense/onnx_wrapper.cpp b/eval/src/vespa/eval/tensor/dense/onnx_wrapper.cpp index 0dc8b343627..521d2382666 100644 --- a/eval/src/vespa/eval/tensor/dense/onnx_wrapper.cpp +++ b/eval/src/vespa/eval/tensor/dense/onnx_wrapper.cpp @@ -1,8 +1,8 @@ // Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "onnx_wrapper.h" +#include <vespa/eval/eval/dense_cells_value.h> #include <vespa/eval/eval/value_type.h> -#include "dense_tensor.h" #include <vespa/vespalib/util/arrayref.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/util/typify.h> @@ -20,6 +20,7 @@ using vespalib::ArrayRef; using vespalib::ConstArrayRef; using vespalib::eval::CellType; using vespalib::eval::DenseValueView; +using vespalib::eval::DenseCellsValue; using vespalib::eval::TypedCells; using vespalib::eval::TypifyCellType; using vespalib::eval::ValueType; @@ -85,7 +86,7 @@ struct CreateVespaTensor { template <typename T> static eval::Value::UP invoke(const eval::ValueType &type) { size_t num_cells = type.dense_subspace_size(); std::vector<T> cells(num_cells, T{}); - return std::make_unique<DenseTensor<T>>(type, std::move(cells)); + return std::make_unique<DenseCellsValue<T>>(type, std::move(cells)); } eval::Value::UP operator()(const eval::ValueType &type) { return typify_invoke<1,MyTypify,CreateVespaTensor>(type.cell_type(), type); diff --git a/eval/src/vespa/eval/tensor/dense/onnx_wrapper.h b/eval/src/vespa/eval/tensor/dense/onnx_wrapper.h index 1f043a7de5e..f42b926d17e 100644 --- a/eval/src/vespa/eval/tensor/dense/onnx_wrapper.h +++ b/eval/src/vespa/eval/tensor/dense/onnx_wrapper.h @@ -2,7 +2,6 @@ #pragma once -#include "dense_tensor_view.h" #ifdef __APPLE__ #include <onnxruntime/core/session/onnxruntime_cxx_api.h> #else @@ -10,6 +9,7 @@ #endif #include <vespa/vespalib/stllike/string.h> #include <vespa/eval/eval/value_type.h> +#include <vespa/eval/eval/value.h> #include <vector> #include <map> #include <set> |