npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@specs-feup/onnx2dfg

v1.0.0

Published

Tool to convert an ONNX graph into a data-flow graph (DFG), decomposing its high-level operations into low-level operations and performing a set of optimizations.

Downloads

62

Readme

ONNX2DFG

Tool to convert an ONNX graph into a data-flow graph, decomposing its high-level operations into low-level operations and performing a set of optimizations. The resulting graph maintains its initial structure, that is (as in all ONNX graphs), the nodes represent operations, initial inputs, and final outputs.

Installation

To install the package:

npm install @specs-feup/onnx2dfg

CLI Usage

Usage: onnx2dfg <input_file> [options]

Options:
      --version                Show version number                      [boolean]
  -o, --output                 Output resulting graph to a file         [string]
  -f, --format                 Output format (json or dot)              [string] [choices: "json", "dot"] [default: "json"]
  -v, --verbosity              Control verbosity (0 = silent, 1 = normal/outputs, 2 = verbose)                          [number] [default: 1]
      --noLowLevel, --nl       Disable the low-level conversion         [boolean] [default: false]
      --noOptimize, --no       Disable optimization steps               [boolean] [default: false]
      --noCodegen, --nc        Disable code generation step             [boolean] [default: false]
      --visualization, --vz    Choose visualization option (0 = none, 1 = Graphviz online link, 2 = Graphviz server)    [number] [default: 2]
      --help                   Show help                                [boolean]

You need to provide an input file (ONNX or JSON)

Programmatic Usage

In addition to the CLI, ONNX2DFG can be used programmatically by importing its functions in your project. This allows you to parse ONNX files, manipulate data-flow graphs, and generate outputs programmatically. The available functions are the following:

onnxFileParser

Parses an ONNX file or JSON graph into an ONNX object.

  • Input:
    • Path of input file (string)
  • Output: ONNX graph parsed into a JSON file (json)
import { onnxFileParser } from "@specs-feup/onnx2dfg";

const onnxObject = await onnxFileParser("path/to/file.onnx");
console.log(onnxObject);

loadGraph

Loads an ONNX object into a data-flow graph and optionally applies low-level transformations and optimizations.

  • Input:
    • ONNX graph parsed into a JSON file (json)
    • Enable low-level operation decomposition (boolean)
    • Enable optimizations (boolean)
    • Convert output to DOT format (boolean)
  • Output: Resulting flow graph, either the object or in DOT format depending on the option chosen (flow graph or string)
import { loadGraph } from "@specs-feup/onnx2dfg";

const dotGraph = loadGraph(onnxObject, true, true, true); // Enable both low-level and optimization steps and convert output to DOT format
console.log(dotGraph);

renderDotToSVG

Converts a DOT graph string into an SVG string for rendering or embedding.

  • Input:
    • Source graph in DOT format (string)
  • Output: SVG image of the graph (string)
import { renderDotToSVG } from "@specs-feup/onnx2dfg";

const dotGraph = "digraph { a -> b }";
const svgContent = await renderDotToSVG(dotGraph);
console.log(svgContent);

generateGraphvizOnlineLink

Generates a link to visualize a DOT graph on Graphviz Online.

  • Input:
    • Source graph in DOT format (string)
  • Output: Link to open the given graph in Graphviz Online (string)
import { generateGraphvizOnlineLink } from "@specs-feup/onnx2dfg";

const dotGraph = "digraph { a -> b }";
const link = generateGraphvizOnlineLink(dotGraph);
console.log(link); // Outputs: https://dreampuf.github.io/GraphvizOnline/#...

generateGraphCode

Generates code from a data-flow graph.

  • Input:
    • Source flow graph (with low-level decomposition applied) (flow graph)
  • Output: Code corresponding to the source graph (string)
import { generateGraphCode } from "@specs-feup/onnx2dfg";

const code = generateGraphCode(graph);
console.log(code);

License

Licensed under the Apache 2.0 License.