Coder Social home page Coder Social logo

wschin / onnxruntime Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoft/onnxruntime

0.0 1.0 0.0 493.77 MB

ONNX Runtime: cross-platform, high performance scoring engine for ML models

Home Page: https://aka.ms/onnxruntime

License: MIT License

Batchfile 0.03% Shell 0.23% CMake 0.96% C# 4.38% C++ 74.22% C 1.77% PowerShell 0.03% Python 9.35% Assembly 3.36% Cuda 1.96% Dockerfile 0.02% Objective-C 0.29% Java 0.70% HLSL 0.02% Jupyter Notebook 0.42% Pascal 0.02% Kotlin 0.01% JavaScript 0.40% TypeScript 1.84% Swift 0.01%

onnxruntime's Introduction

ONNX Runtime is a cross-platform inference and training machine-learning accelerator.

ONNX Runtime inference can enable faster customer experiences and lower costs, supporting models from deep learning frameworks such as PyTorch and TensorFlow/Keras as well as classical machine learning libraries such as scikit-learn, LightGBM, XGBoost, etc. ONNX Runtime is compatible with different hardware, drivers, and operating systems, and provides optimal performance by leveraging hardware accelerators where applicable alongside graph optimizations and transforms. Learn more โ†’

ONNX Runtime training can accelerate the model training time on multi-node NVIDIA GPUs for transformer models with a one-line addition for existing PyTorch training scripts. Learn more โ†’

Get Started

General Information: onnxruntime.ai

Usage documention and tutorials: onnxruntime.ai/docs

Companion sample repositories:

Build Pipeline Status

System CPU GPU EPs
Windows Build Status Build Status Build Status
Linux Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Mac Build Status
Build Status
Android Build Status
iOS Build Status
WebAssembly Build Status

Data/Telemetry

Windows distributions of this project may collect usage data and send it to Microsoft to help improve our products and services. See the privacy statement for more details.

Contributions and Feedback

We welcome contributions! Please see the contribution guidelines.

For feature requests or bug reports, please file a GitHub Issue.

For general discussion or questions, please use GitHub Discussions.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

License

This project is licensed under the MIT License.

onnxruntime's People

Contributors

askhade avatar baijumeswani avatar edgchen1 avatar er3x3 avatar fdwr avatar fs-eire avatar guoyu-wang avatar hariharans29 avatar hectorsvc avatar jeffbloo avatar jignparm avatar jywu-msft avatar liqunfu avatar pranavsharma avatar randysheriffh avatar ryanunderhill avatar shahasad avatar sherlocknomad avatar skottmckay avatar smk2007 avatar snnn avatar tiagoshibata avatar tianleiwu avatar tracysh avatar wangyems avatar xadupre avatar ytaous avatar yufenglee avatar yuslepukhin avatar zhanghuanrong avatar

Watchers

 avatar

onnxruntime's Issues

Unregister LazyTensor backend

As title. We call

import lazy_tensor_core as lt
import lazy_tensor_core.core.lazy_model as ltm
import torch
import onnxruntime as ort
from onnxruntime.training.ortmodule.torch_cpp_extensions import aten_op_executor
from onnxruntime.capi import _pybind_state as C

# Set up ORT as Pytorch backend
lt._LAZYC._ltc_init_ts_backend()
C.register_aten_op_executor(str(aten_op_executor.is_tensor_argument_address()),
                            str(aten_op_executor.execute_aten_operator_address()))
ost.register_ort_as_torch_jit_executor()

to register ORT as Pytorch backend (via LazyTensor). We should also have a function to reverse this action.

Return byte arrays as exporting result

Current exporting flow is

  1. Pytorch creates ONNX graph in memory.
  2. Pytorch saves ONNX graph to disk.
  3. ORT loads ONNX graph from disk.

Ideally, step (2) is not necessary and we should remove it.

Print helper functions

We need helper to print types and shapes for at::IValue and OrtValue. It's helpful for debugging.

Support `aten::add`

aten::add is not supported because

  • ONNX exporter doesn't handle scalar correctly.
  • After applying Bowen's patch, LazyTensor generates incorrect sub-graph. The last input to aten::add should be at::Scalar but got at::Tensor.

Only Add GPU EP when Input Tensors Are on GPU

Currently, we use GPU EP for both CPU and GPU tensors.

[Update] The problem is deeper than I thought. With ORT built with USE_CUDA=1, some CUDA-specific graph fusion may be applied and ORT may throw if GPU EP is not registered. We move some graph transformations to under their EPs and then come back to fix this problem.

Support `aten::nll_loss_forward`

Got an error

RuntimeError: outputs_.size() == 1INTERNAL ASSERT FAILED at "../torch/csrc/jit/ir/ir.h":500, please report a bug to PyTorch. 

when running LazyTensor-ORT with the following script.

from __future__ import print_function
import argparse
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import lazy_tensor_core
from onnxruntime.capi import _pybind_state as ost
import lazy_tensor_core.core.lazy_model as ltm
torch.manual_seed(0)

ost.register_ort_as_torch_jit_executor()
lazy_tensor_core._LAZYC._ltc_init_ts_backend()

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(1, 32, 3, 1, bias=False)
        self.conv2 = nn.Conv2d(32, 64, 3, 1, bias=False)
        self.dropout1 = nn.Dropout(0.25)
        self.dropout2 = nn.Dropout(0.5)
        self.fc1 = nn.Linear(9216, 128, bias=False)
        self.fc2 = nn.Linear(128, 10, bias=False)

    def forward(self, x):
        x = self.conv1(x)
        x = F.relu(x)
        x = self.conv2(x)
        x = F.relu(x)
        x = F.max_pool2d(x, 2)
        x = self.dropout1(x)
        x = torch.flatten(x, 1)
        x = self.fc1(x)
        x = F.relu(x)
        x = self.dropout2(x)
        x = self.fc2(x)
        output = F.log_softmax(x, dim=1)
        return output

device = 'lazy'
x = torch.rand((64, 1, 28, 28), dtype=torch.float32).to(device)
y = torch.randint(0, 9, (64,), dtype=torch.int64).to(device)
model = Net().to(device)
optimizer = optim.Adagrad(model.parameters(), lr=0.001)
for i in range(5):
  print(i)
  optimizer.zero_grad()
  print(f'tr::forward::{i}')
  output = model(x)
  ltm.mark_step()
  print('tr:loss')
  loss = F.nll_loss(output, y)
  print(loss)
  print(f'tr::backward::{i}')
  loss.backward() #2.1838
  ltm.mark_step()
  print(f'tr::optim::{i}')
  optimizer.step()
  ltm.mark_step()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.