Skip to content

rxwei/swift-tensorflow-profiling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unofficial Swift for TensorFlow profiling suite

This repository contains pairs of Python TensorFlow programs and Swift TensorFlow programs for a head-to-head performance comparison.

All tests will report the interval between graph launch and graph finish.

Note: The timer in Swift will also include graph deserialization time, so comparisons below are not entirely unfair. I'm working to add hooks in the compiler runtime to just time the call to TF_SessionRun.

My testing environment

  • macOS Mojave (18A336e)
  • 4.2 GHz Intel Core i7
  • TensorFlow 1.9
  • Swift for TensorFlow rev 5b36279

Benchmarks

Graphs with the same ops and control flow constructs

Basic operations are being tested here: matrix multiplication, convolution and loops.

Python Swift
axpy_unrolled 0.7358s 1.7969s
axpy_loop 0.3705s 0.5781s

tf.Variable vs. functional

Graph Program Extraction currently does not generate mutable variables in the TensorFlow graph for var declarations. Instead, each mutation of var in Swift source code gets lowered to producing a new value. In Python, however, tf.Variable is used everywhere and may be highly optimized. Here we compare purely functional parameter updates with mutation-based parameter updates.

Python Swift
parameter_update 0.8749s 1.4375s

Vanilla models

Coming soon

About

Swift for TensorFlow profiling suite

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published