#include #include Ort::Env env(ORT_LOGGING_LEVEL_WARNING, "test"); const auto& api = Ort::GetApi(); OrtTensorRTProviderOptionsV2* tensorrt_options; Ort::SessionOptions session_options; Ort::AllocatorWithDefaultOptions allocator; auto memory_info = Ort::MemoryInfo::CreateCpu(OrtArenaAllocator, OrtMemTypeDefault); std::vector ortVal2Vector(Ort::Value &tensor, int tensor_length){ /** * convert ort tensor to vector */ float* floatarr = tensor.GetTensorMutableData(); std::vector vector {floatarr, floatarr + tensor_length}; return vector; } void print_onnx_forward_output(std::vector &output_tensors, int num){ float* floatarr = output_tensors.front().GetTensorMutableData(); for (int i = 0; i < num; i++) printf("[%d] = %f\n", i, floatarr[i]); } void print_shape_of_ort_val(std::vector &tensor){ auto out_shape = tensor.front().GetTensorTypeAndShapeInfo().GetShape(); auto out_size = out_shape.size(); std::cout << "("; for (int i=0; i input_node_names(num_input_nodes); std::vector input_node_dims; printf("Number of inputs = %zu\n", num_input_nodes); char* output_name = session.GetOutputName(0, allocator); printf("output name: %s\n", output_name); // iterate over all input nodes for (int i = 0; i < num_input_nodes; i++) { // print input node names char* input_name = session.GetInputName(i, allocator); printf("Input %d : name=%s\n", i, input_name); input_node_names[i] = input_name; // print input node types Ort::TypeInfo type_info = session.GetInputTypeInfo(i); auto tensor_info = type_info.GetTensorTypeAndShapeInfo(); ONNXTensorElementDataType type = tensor_info.GetElementType(); printf("Input %d : type=%d\n", i, type); // print input shapes/dims input_node_dims = tensor_info.GetShape(); printf("Input %d : num_dims=%zu\n", i, input_node_dims.size()); for (size_t j = 0; j < input_node_dims.size(); j++) printf("Input %d : dim %zu=%jd\n", i, j, input_node_dims[j]); } std::cout << "=======================================" << std::endl; }