Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[MXNET-703] Fix relative import in TensorRT #12122

Closed
Closed
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
268e90b
[MXNET-703] TensorRT runtime integration
Jun 18, 2018
4855d8a
correctly assign self._optimized_symbol in executor
Caenorst Jul 25, 2018
419b294
declare GetTrtCompatibleSubsets and ReplaceSubgraph only if MXNET_USE…
Caenorst Jul 25, 2018
8d723c9
add comments in ReplaceSubgraph
Caenorst Jul 25, 2018
ca94624
Addressing Haibin's code review points
Jul 26, 2018
75c8642
Check that shared_buffer is not empty when USE_TENSORRT is set
Jul 26, 2018
2a11466
Added check that TensorRT binding is for inference only
Jul 26, 2018
190c9bf
Removed redundant decl.
mkolod Aug 2, 2018
d88ad8b
WIP Refactored TRT integration and tests
KellenSunderland Aug 8, 2018
87ebdce
Add more build guards, remove unused code
KellenSunderland Aug 8, 2018
83fa475
Remove ccache report
KellenSunderland Aug 8, 2018
4a3772f
Remove redundant const in declaration
KellenSunderland Aug 8, 2018
f779537
Clean Cmake TRT files
KellenSunderland Aug 8, 2018
b0748ef
Remove TensorRT env var usage
KellenSunderland Aug 8, 2018
35e1367
Use contrib optimize_graph instaed of bind
KellenSunderland Aug 8, 2018
6338e45
Clean up cycle detector
KellenSunderland Aug 8, 2018
21d0239
Convert lenet test to contrib optimize
KellenSunderland Aug 8, 2018
f30dbef
Protect interface with trt build flag
KellenSunderland Aug 8, 2018
eaba593
Fix whitespace issues
KellenSunderland Aug 8, 2018
f870a3f
Add another build guard to c_api
KellenSunderland Aug 8, 2018
e40d6b3
Move get_optimized_symbol to contrib area
KellenSunderland Aug 8, 2018
7fa6a4a
Ignore gz files in test folder
KellenSunderland Aug 9, 2018
e777ab5
Make trt optimization implicit
KellenSunderland Aug 9, 2018
3ea9b89
Remove unused declaration
KellenSunderland Aug 9, 2018
d6d2cac
Replace build guards with runtime errors
KellenSunderland Aug 9, 2018
2d04aee
Change default value of TensorRT to off
KellenSunderland Aug 9, 2018
449a195
Warn user when TRT not active at runtime
KellenSunderland Aug 9, 2018
ed36739
Move TensorRTBind declaration, add descriptive errors
KellenSunderland Aug 9, 2018
882d8e5
Test TensorRT graph execution, fix bugs
KellenSunderland Aug 9, 2018
95a7955
Fix lint and whitespace issues
KellenSunderland Aug 9, 2018
0307467
Fix typo
KellenSunderland Aug 9, 2018
8504319
Removed default value for set_use_tensorrt
KellenSunderland Aug 9, 2018
55dd422
Improved documentation and fixed spacing issues
KellenSunderland Aug 9, 2018
ec9d3ea
Move static exec funcs to util files
KellenSunderland Aug 9, 2018
4b63738
Update comments to match util style
KellenSunderland Aug 9, 2018
694cbfb
Apply const to loop element
KellenSunderland Aug 9, 2018
2be7d25
Fix a few namespace issues
KellenSunderland Aug 9, 2018
369a3f7
Make static funcs inline to avoid compiler warning
KellenSunderland Aug 9, 2018
1c7698b
Remove unused inference code from lenet5_train
KellenSunderland Aug 10, 2018
74b6603
Add explicit trt contrib bind, update tests to use it
KellenSunderland Aug 10, 2018
7fff80c
Rename trt bind call
KellenSunderland Aug 10, 2018
a754aab
Remove documentation that is not needed for trt
KellenSunderland Aug 10, 2018
22a3823
Reorder arguments, allow position calling
KellenSunderland Aug 10, 2018
76b03eb
Use relative path for symbol import
KellenSunderland Aug 10, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove unused inference code from lenet5_train
KellenSunderland committed Aug 10, 2018

Unverified

This user has not yet uploaded their public signing key.
commit 1c7698bb92e100580aec9f8e828a2f566de580ff
40 changes: 2 additions & 38 deletions tests/python/tensorrt/lenet5_train.py
Original file line number Diff line number Diff line change
@@ -16,10 +16,10 @@
# under the License.

import os
import numpy as np
import mxnet as mx
from lenet5_common import get_iters


def lenet5():
"""LeNet-5 Symbol"""
#pylint: disable=no-member
@@ -44,6 +44,7 @@ def lenet5():
#pylint: enable=no-member
return lenet


def train_lenet5(num_epochs, batch_size, train_iter, val_iter, test_iter):
"""train LeNet-5 model on MNIST data"""
ctx = mx.gpu(0)
@@ -65,44 +66,7 @@ def train_lenet5(num_epochs, batch_size, train_iter, val_iter, test_iter):
return lenet_model


def run_inference(sym, arg_params, aux_params, mnist, all_test_labels, batch_size):
"""Run inference with either MXNet or TensorRT"""

shared_buffer = merge_dicts(arg_params, aux_params)
if not get_use_tensorrt():
shared_buffer = dict([(k, v.as_in_context(mx.gpu(0))) for k, v in shared_buffer.items()])
executor = sym.simple_bind(ctx=mx.gpu(0),
data=(batch_size,) + mnist['test_data'].shape[1:],
softmax_label=(batch_size,),
shared_buffer=shared_buffer,
grad_req='null',
force_rebind=True)

# Get this value from all_test_labels
# Also get classes from the dataset
num_ex = 10000
all_preds = np.zeros([num_ex, 10])
test_iter = mx.io.NDArrayIter(mnist['test_data'], mnist['test_label'], batch_size)

example_ct = 0

for idx, dbatch in enumerate(test_iter):
executor.arg_dict["data"][:] = dbatch.data[0]
executor.forward(is_train=False)
offset = idx*batch_size
extent = batch_size if num_ex - offset > batch_size else num_ex - offset
all_preds[offset:offset+extent, :] = executor.outputs[0].asnumpy()[:extent]
example_ct += extent

all_preds = np.argmax(all_preds, axis=1)
matches = (all_preds[:example_ct] == all_test_labels[:example_ct]).sum()

percentage = 100.0 * matches / example_ct

return percentage

if __name__ == '__main__':

num_epochs = 10
batch_size = 128
model_name = 'lenet5'