Fetching contributors…
Cannot retrieve contributors at this time
14 lines (12 sloc) 899 Bytes

Generate C# code from ONNX proto file

  1. Download onnx-ml.proto3 from
  2. Download protobuf C# compiler version 3.0 or greater from
  3. Add option csharp_namespace = "Microsoft.ML.Runtime.UniversalModelFormat.Onnx"; to onnx-ml.proto3 right below package ONNX_NAMESPACE;
  4. Assuming the compiler and proto file are saved at E:\protobuf-csharp-port\lib then run the following in command line to get C# code from the proto file:
    protoc.exe -I="E:\protobuf-csharp-port\lib" --csharp_out="E:\protobuf-csharp-port\lib" "E:\protobuf-csharp-port\lib\onnx-ml.proto3"

The proto3 file is current as of 06/01/2018 and generated from onnx-ml.proto3 based on the following commit