Skip to content

Commit

Permalink
add-caffe-test (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
lanpa committed Jul 3, 2019
1 parent e0b8b67 commit 0a230d9
Show file tree
Hide file tree
Showing 4 changed files with 1,371 additions and 52 deletions.
6 changes: 3 additions & 3 deletions tensorboardX/caffe2_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ def _operators_to_graph_def(
if show_simplified: # use_tensorflow_naming
_rename_tensorflow_style(shapes, blob_name_tracker, ops)
producing_ops = {}
blobs = set()
blobs = []
input_blobs, inter_blobs, _ = _compute_in_out(ops)
current_graph = GraphDef()
seen = set(input_blobs)
Expand All @@ -699,9 +699,9 @@ def _operators_to_graph_def(
[_operator_to_node(shapes, op)] # .extend() expects an iterable
current_graph.node.extend(nodes_from_op)
for input_blob in op.input:
blobs.add(input_blob)
blobs.append(input_blob)
for i, output_blob in enumerate(op.output):
blobs.add(output_blob)
blobs.append(output_blob)
producing_ops.setdefault(output_blob, []).append((op, i))

if show_simplified:
Expand Down
319 changes: 319 additions & 0 deletions tests/expect/test_caffe2.test_simple_cnnmodel.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,319 @@
node {
name: "conv1/XavierFill"
op: "XavierFill"
attr {
key: "_output_shapes"
value {
list {
shape {
dim {
size: 96
}
dim {
size: 3
}
dim {
size: 11
}
dim {
size: 11
}
}
}
}
}
}
node {
name: "conv1/ConstantFill"
op: "ConstantFill"
attr {
key: "_output_shapes"
value {
list {
shape {
dim {
size: 96
}
}
}
}
}
}
node {
name: "classifier/XavierFill"
op: "XavierFill"
attr {
key: "_output_shapes"
value {
list {
shape {
dim {
size: 1000
}
dim {
size: 4096
}
}
}
}
}
}
node {
name: "classifier/ConstantFill"
op: "ConstantFill"
attr {
key: "_output_shapes"
value {
list {
shape {
dim {
size: 1000
}
}
}
}
}
}
node {
name: "conv1/Conv"
op: "Conv"
input: "conv1/data"
input: "conv1/conv1_w"
input: "conv1/conv1_b"
attr {
key: "exhaustive_search"
value {
i: 0
}
}
attr {
key: "kernel"
value {
i: 11
}
}
attr {
key: "order"
value {
s: "NCHW"
}
}
attr {
key: "stride"
value {
i: 4
}
}
}
node {
name: "conv1/Relu"
op: "Relu"
input: "conv1/conv1"
attr {
key: "cudnn_exhaustive_search"
value {
i: 0
}
}
attr {
key: "order"
value {
s: "NCHW"
}
}
}
node {
name: "conv1/MaxPool"
op: "MaxPool"
input: "conv1/conv1_1"
attr {
key: "cudnn_exhaustive_search"
value {
i: 0
}
}
attr {
key: "kernel"
value {
i: 2
}
}
attr {
key: "order"
value {
s: "NCHW"
}
}
attr {
key: "stride"
value {
i: 2
}
}
}
node {
name: "classifier/FC"
op: "FC"
input: "conv1/pool1"
input: "classifier/fc_w"
input: "classifier/fc_b"
attr {
key: "cudnn_exhaustive_search"
value {
i: 0
}
}
attr {
key: "order"
value {
s: "NCHW"
}
}
attr {
key: "use_cudnn"
value {
i: 1
}
}
}
node {
name: "classifier/Softmax"
op: "Softmax"
input: "classifier/fc"
attr {
key: "cudnn_exhaustive_search"
value {
i: 0
}
}
attr {
key: "order"
value {
s: "NCHW"
}
}
}
node {
name: "classifier/LabelCrossEntropy"
op: "LabelCrossEntropy"
input: "classifier/pred"
input: "classifier/label"
}
node {
name: "classifier/AveragedLoss"
op: "AveragedLoss"
input: "classifier/xent"
}
node {
name: "conv1/conv1_w"
op: "Blob"
input: "conv1/XavierFill:0"
}
node {
name: "conv1/conv1_b"
op: "Blob"
input: "conv1/ConstantFill:0"
}
node {
name: "classifier/fc_w"
op: "Blob"
input: "classifier/XavierFill:0"
}
node {
name: "classifier/fc_b"
op: "Blob"
input: "classifier/ConstantFill:0"
}
node {
name: "conv1/data"
op: "Placeholder"
}
node {
name: "conv1/conv1_w"
op: "Blob"
input: "conv1/XavierFill:0"
}
node {
name: "conv1/conv1_b"
op: "Blob"
input: "conv1/ConstantFill:0"
}
node {
name: "conv1/conv1"
op: "Blob"
input: "conv1/Conv:0"
}
node {
name: "conv1/conv1"
op: "Blob"
input: "conv1/Conv:0"
}
node {
name: "conv1/conv1_1"
op: "Blob"
input: "conv1/Relu:0"
}
node {
name: "conv1/conv1_1"
op: "Blob"
input: "conv1/Relu:0"
}
node {
name: "conv1/pool1"
op: "Blob"
input: "conv1/MaxPool:0"
}
node {
name: "conv1/pool1"
op: "Blob"
input: "conv1/MaxPool:0"
}
node {
name: "classifier/fc_w"
op: "Blob"
input: "classifier/XavierFill:0"
}
node {
name: "classifier/fc_b"
op: "Blob"
input: "classifier/ConstantFill:0"
}
node {
name: "classifier/fc"
op: "Blob"
input: "classifier/FC:0"
}
node {
name: "classifier/fc"
op: "Blob"
input: "classifier/FC:0"
}
node {
name: "classifier/pred"
op: "Blob"
input: "classifier/Softmax:0"
}
node {
name: "classifier/pred"
op: "Blob"
input: "classifier/Softmax:0"
}
node {
name: "classifier/label"
op: "Placeholder"
}
node {
name: "classifier/xent"
op: "Blob"
input: "classifier/LabelCrossEntropy:0"
}
node {
name: "classifier/xent"
op: "Blob"
input: "classifier/LabelCrossEntropy:0"
}
node {
name: "classifier/loss"
op: "Blob"
input: "classifier/AveragedLoss:0"
}

0 comments on commit 0a230d9

Please sign in to comment.