onnxruntime/onnxruntime/test/framework/tensorprotoutils_test.cc
Ryan Hill 11b369a864
Abbreviate ONNXRuntime as Ort in all of our public APIs (#175)
Applies to all public headers and macros, plus many internal ones. There are still some internal things with OnnxRuntime in the name, but this fixes all public functions & macros.
2018-12-14 14:54:23 -08:00

31 lines
1.1 KiB
C++

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "core/platform/env.h"
#include "core/framework/tensor.h"
#include "core/graph/onnx_protobuf.h"
#include "core/framework/tensorprotoutils.h"
#include "gtest/gtest.h"
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <sstream>
namespace onnxruntime {
namespace test {
#ifdef ORT_RUN_EXTERNAL_ONNX_TESTS
TEST(TensorProtoUtilsTest, test1) {
const char* filename = "../models/opset8/test_resnet50/test_data_set_0/input_0.pb";
int test_data_pb_fd;
common::Status st = Env::Default().FileOpenRd(filename, test_data_pb_fd);
ASSERT_TRUE(st.IsOK());
google::protobuf::io::FileInputStream f(test_data_pb_fd);
f.SetCloseOnDelete(true);
ONNX_NAMESPACE::TensorProto proto;
ASSERT_TRUE(proto.ParseFromZeroCopyStream(&f));
std::unique_ptr<Tensor> tensor;
::onnxruntime::AllocatorPtr cpu_allocator = std::make_shared<::onnxruntime::CPUAllocator>();
st = ::onnxruntime::utils::GetTensorFromTensorProto(proto, &tensor, cpu_allocator);
ASSERT_TRUE(st.IsOK());
}
#endif
} // namespace test
} // namespace onnxruntime