Skip to content

Instantly share code, notes, and snippets.

View pranavsharma's full-sized avatar

Pranav Sharma pranavsharma

View GitHub Profile
TEST(InferenceSessionTests, TestIssue2404) {
string model_uri = "testdata/test_model.onnx";
SessionOptions so;
//so.session_logid = "InferenceSessionTests." + log_str;
//so.session_log_verbosity_level = 1; // change to 1 for detailed logging
InferenceSession session_object{so, &DefaultLoggingManager()};
CUDAExecutionProviderInfo epi;
epi.device_id = 0;
@pranavsharma
pranavsharma / test_onnx_model.py
Last active May 12, 2020 19:09
Test ONNX model with random input data
import numpy as np
import onnx
from onnx import numpy_helper
from onnx import mapping
from onnx import TensorProto
import onnxruntime as rt
def create_random_data(shape, type, minvalue, maxvalue, seed):
import numpy as np
import sys
import onnx
from onnx import numpy_helper
from onnx import mapping
from onnx import TensorProto
import onnxruntime as rt
import timeit
def create_random_data(shape, type, minvalue, maxvalue, seed):
@pranavsharma
pranavsharma / Program.cs
Last active July 29, 2021 16:47
Test program for Issue 4070
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Microsoft.ML.OnnxRuntime;
using Microsoft.ML.OnnxRuntime.Tensors;
@pranavsharma
pranavsharma / t-ort.py
Last active July 29, 2021 16:49
Test ORT python API using GPU and iobinding
import numpy as np
import onnxruntime
import time
import timeit
def create_random_data(shape, type, minvalue, maxvalue, seed):
nptype = np.dtype(type)
np.random.seed(seed)
return ((maxvalue - minvalue) * np.random.sample(shape) + minvalue).astype(nptype)
@pranavsharma
pranavsharma / t-ort_gpu.cc
Last active July 29, 2021 16:44
onnxruntime C++ API inferencing example for GPU
// Copyright(c) Microsoft Corporation.All rights reserved.
// Licensed under the MIT License.
// Example of using IOBinding while inferencing with GPU
#include <assert.h>
#include <chrono>
#include <iostream>
#include <onnxruntime_cxx_api.h>
#include <vector>
@pranavsharma
pranavsharma / t-ort.cs
Created July 10, 2021 02:29
Test ORT C# with IOBinding
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Microsoft.ML.OnnxRuntime;
using Microsoft.ML.OnnxRuntime.Tensors;
using System.Diagnostics;
@pranavsharma
pranavsharma / t-unordered_set_comp.cc
Last active July 29, 2021 16:43
Example of using lambda as a comparator for unordered_set
#include <iostream>
#include <string>
#include <unordered_set>
#include <functional>
#include <assert.h>
using namespace std;
struct Foo {
string name;
};
@pranavsharma
pranavsharma / t-ortcpu.cc
Last active September 9, 2021 20:06
onnxruntime C++ API inferencing example for CPU
// Copyright(c) Microsoft Corporation.All rights reserved.
// Licensed under the MIT License.
//
/*
pranav@XXX:~$ wget https://github.com/microsoft/onnxruntime/releases/download/v1.8.1/onnxruntime-linux-x64-1.8.1.tgz
....
2021-07-28 19:44:06 (7.60 MB/s) - ‘onnxruntime-linux-x64-1.8.1.tgz’ saved [4736207/4736207]
pranav@XXX:~$ tar xvfz onnxruntime-linux-x64-1.8.1.tgz
@pranavsharma
pranavsharma / test_linkedin_model_perf.cc
Last active September 17, 2021 19:46
Test LinkedIn model perf
// Copyright(c) Microsoft Corporation.All rights reserved.
// Licensed under the MIT License.
//
/*
INSTRUCTION TO COMPILE AND RUN
===============================
pranav@XXX:~$ wget
https://github.com/microsoft/onnxruntime/releases/download/v1.8.1/onnxruntime-linux-x64-1.8.1.tgz
....