Skip to content

Commit

Permalink
Move nanopb-generated ONNX to unique file name (pytorch#8773)
Browse files Browse the repository at this point in the history
* Move nanopb-generated ONNX to unique file name

* fix other places
  • Loading branch information
orionr authored and soumith committed Jun 22, 2018
1 parent 9c42679 commit 5a7b484
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ def run(self):
"torch/csrc/autograd/functions/init.cpp",
"torch/csrc/nn/THNN.cpp",
"torch/csrc/tensor/python_tensor.cpp",
"torch/csrc/onnx/onnx.pb.cpp",
"torch/csrc/onnx/onnx.npb.cpp",
"torch/csrc/onnx/onnx.cpp",
"torch/csrc/onnx/init.cpp",
]
Expand Down
5 changes: 3 additions & 2 deletions tools/gen_onnx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ protoc --plugin=protoc-gen-nanopb=$PWD/torch/lib/nanopb/generator/protoc-gen-nan
--nanopb_out=-T:.
# NB: -T suppresses timestamp. See https://github.com/nanopb/nanopb/issues/274
# nanopb generated C files are valid CPP! Yay!
cp $TEMP_DIR/onnx.pb.c torch/csrc/onnx/onnx.pb.cpp
cp $TEMP_DIR/onnx.pb.h torch/csrc/onnx/onnx.pb.h
cp $TEMP_DIR/onnx.pb.c torch/csrc/onnx/onnx.npb.cpp
sed -i s'/\(#include.*onnx\).pb.h/\1.npb.h/' torch/csrc/onnx/onnx.npb.cpp
cp $TEMP_DIR/onnx.pb.h torch/csrc/onnx/onnx.npb.h

rm -r $TEMP_DIR
2 changes: 1 addition & 1 deletion torch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ set(TORCH_SRCS
${TORCH_SRC_DIR}/csrc/jit/export.cpp
${TORCH_SRC_DIR}/csrc/jit/import.cpp
${TORCH_SRC_DIR}/csrc/onnx/onnx.cpp
${TORCH_SRC_DIR}/csrc/onnx/onnx.pb.cpp
${TORCH_SRC_DIR}/csrc/onnx/onnx.npb.cpp
${TORCH_SRC_DIR}/csrc/torch.cpp)

if (NOT NO_API)
Expand Down
2 changes: 1 addition & 1 deletion torch/csrc/jit/import.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "torch/csrc/jit/import.h"
#include "torch/csrc/onnx/onnx.pb.h"
#include "torch/csrc/onnx/onnx.npb.h"
#include "torch/csrc/jit/ir.h"
#include "torch/csrc/utils/functional.h"

Expand Down
2 changes: 1 addition & 1 deletion torch/csrc/onnx/init.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "torch/csrc/onnx/init.h"
#include "torch/csrc/onnx/onnx.pb.h"
#include "torch/csrc/onnx/onnx.npb.h"
#include "torch/csrc/onnx/onnx.h"

namespace torch { namespace onnx {
Expand Down
2 changes: 1 addition & 1 deletion torch/csrc/onnx/onnx.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "torch/csrc/onnx/onnx.pb.h"
#include "torch/csrc/onnx/onnx.npb.h"
#include "torch/csrc/assertions.h"

#include <pb_encode.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Automatically generated nanopb constant definitions */
/* Generated by nanopb-0.3.9-dev */

#include "onnx.pb.h"
#include "onnx.npb.h"

/* @@protoc_insertion_point(includes) */
#if PB_PROTO_HEADER_VERSION != 30
Expand Down
File renamed without changes.

0 comments on commit 5a7b484

Please sign in to comment.