Coder Social home page Coder Social logo

wschin / pytorch_compiler_tutorial Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bwasti/pytorch_compiler_tutorial

0.0 1.0 0.0 27 KB

Codebase associated with the PyTorch compiler tutorial

CMake 8.88% Shell 1.19% C++ 55.94% Python 34.00%

pytorch_compiler_tutorial's Introduction

This is the codebase associated with the PyTorch JIT compiler tutorial.

Build and Test

A recent version of PyTorch will likely need to have been installed (either nightly or built from source).

git clone https://github.com/bwasti/pytorch_compiler_tutorial.git --recursive
cd pytorch_compiler_tutorial
./build.sh
PYTHONPATH=build python test.py

This test benchmarks the following function with inputs of size 1024, run 100 times:

def foo(a, b):
  c = a.mul(b)
  a = c.mul(c)
  a = c.mul(a)
  return a

We expect to see this output:

-- Default IR --
 graph(%a.1 : Float(*),
      %b.1 : Float(*)):
  %c.1 : Float(*) = aten::mul(%a.1, %b.1) # test.py:20:7
  %a.3 : Float(*) = aten::mul(%c.1, %c.1) # test.py:21:7
  %a.5 : Float(*) = aten::mul(%c.1, %a.3) # test.py:22:7
  return (%a.5)

Default version took 26.74ms

-- Transformed IR --
 graph(%a.1 : Float(*),
      %b.1 : Float(*)):
  %a.5 : Float(*) = pw::CompilationGroup_0(%a.1, %b.1)
  return (%a.5)
with pw::CompilationGroup_0 = graph(%4 : Float(*),
      %5 : Float(*)):
  %c.1 : Float(*) = aten::mul(%4, %5) # test.py:34:7
  %a.3 : Float(*) = aten::mul(%c.1, %c.1) # test.py:35:7
  %a.5 : Float(*) = aten::mul(%c.1, %a.3) # test.py:36:7
  return (%a.5)

Compiled version took 8.20ms

pytorch_compiler_tutorial's People

Contributors

bwasti avatar wschin avatar

Watchers

 avatar

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.