microsoft/onnxruntime-extensions
Publicmirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable
test/shared_test/test_ortops_strings.cc
32lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | #include <filesystem> |
| 5 | #include "gtest/gtest.h" |
| 6 | #include "ocos.h" |
| 7 | #include "test_kernel.hpp" |
| 8 | #include "text/string_lower.hpp" |
| 9 | |
| 10 | |
| 11 | TEST(utils, test_string_lower) { |
| 12 | auto ort_env = std::make_unique<Ort::Env>(ORT_LOGGING_LEVEL_WARNING, "Default"); |
| 13 | |
| 14 | std::vector<TestValue> inputs(1); |
| 15 | inputs[0].name = "input_1"; |
| 16 | inputs[0].element_type = ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING; |
| 17 | inputs[0].dims = {3, 1}; |
| 18 | inputs[0].values_string = {"Abc", "Abcé", "中文"}; |
| 19 | |
| 20 | std::vector<TestValue> outputs(1); |
| 21 | outputs[0].name = "customout"; |
| 22 | outputs[0].element_type = ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING; |
| 23 | outputs[0].dims = inputs[0].dims; |
| 24 | outputs[0].values_string = {"abc", "abcé", "中文"}; |
| 25 | |
| 26 | std::filesystem::path model_path = __FILE__; |
| 27 | model_path = model_path.parent_path(); |
| 28 | model_path /= ".."; |
| 29 | model_path /= "data"; |
| 30 | model_path /= "custom_op_string_lower.onnx"; |
| 31 | TestInference(*ort_env, model_path.c_str(), inputs, outputs, GetLibraryPath()); |
| 32 | } |
| 33 | |