Skip to content

Commit 093de46

Browse files
committed
resolve the conflicts
Signed-off-by: Ruoqian Guo <[email protected]>
2 parents 770b5a2 + aec4e1a commit 093de46

File tree

99 files changed

+2170
-496
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+2170
-496
lines changed

.github/workflows/docgen.yml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,32 @@ on:
1010

1111
jobs:
1212
build-docs:
13-
runs-on: ubuntu-latest
13+
runs-on: ubuntu-18.04
14+
container:
15+
image: docker.pkg.github.com/nvidia/trtorch/docgen:latest
16+
credentials:
17+
username: $GITHUB_ACTOR
18+
password: ${{secrets.GITHUB_TOKEN}}
1419
steps:
1520
- uses: actions/checkout@v2
1621
with:
1722
ref: ${{github.head_ref}}
18-
- name: Docker login
19-
run: docker login docker.pkg.github.com -u $GITHUB_ACTOR -p $GITHUB_TOKEN
20-
env:
21-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
22-
- name: Run image
23-
run: docker run -it -d --name builder -v $GITHUB_WORKSPACE:/workspace -w /workspace docker.pkg.github.com/nvidia/trtorch/docgen:latest
24-
- name: Build python package
25-
run: docker exec builder bash -c "cp docker/WORKSPACE.docker WORKSPACE && cd py && python3 setup.py install"
26-
- name: Generate new docs
27-
run: docker exec builder bash -c "cd docsrc && make html"
23+
- name: Get HEAD SHA
24+
id: vars
25+
run: echo "::set-output name=sha::$(git rev-parse --short HEAD)"
26+
- name: Build Python Package
27+
run: |
28+
cp docker/WORKSPACE.docs WORKSPACE
29+
cd py
30+
python3 setup.py install
31+
- name: Generate New Docs
32+
run: |
33+
cd docsrc
34+
make html
2835
- uses: stefanzweifel/git-auto-commit-action@v4
2936
with:
3037
# Required
31-
commit_message: >
32-
docs: [Automated] Regenerating documenation from ${{github.head_ref}}
38+
commit_message: "docs: [Automated] Regenerating documenation for ${{ steps.vars.outputs.sha }}"
3339
commit_options: "--no-verify --signoff"
3440
file_pattern: docs/
3541
commit_user_name: TRTorch Github Bot

.github/workflows/linter.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Run image
2020
run: |
2121
docker run -it -d --name cpplinter -e GITHUB_TOKEN=$GITHUB_TOKEN -v $GITHUB_WORKSPACE:/workspace -v $GITHUB_EVENT_PATH:/GITHUB_EVENT.json -w /workspace docker.pkg.github.com/nvidia/trtorch/docgen:latest
22-
docker exec cpplinter bash -c "cp /workspace/docker/WORKSPACE.docker /workspace/WORKSPACE"
22+
docker exec cpplinter bash -c "cp /workspace/docker/WORKSPACE.docs /workspace/WORKSPACE"
2323
env:
2424
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
2525
- name: Install dependencies
@@ -41,7 +41,7 @@ jobs:
4141
- name: Run image
4242
run: |
4343
docker run -it -d --name pylinter -e GITHUB_TOKEN=$GITHUB_TOKEN -v $GITHUB_WORKSPACE:/workspace -v $GITHUB_EVENT_PATH:/GITHUB_EVENT.json -w /workspace docker.pkg.github.com/nvidia/trtorch/docgen:latest
44-
docker exec pylinter bash -c "cp /workspace/docker/WORKSPACE.docker /workspace/WORKSPACE"
44+
docker exec pylinter bash -c "cp /workspace/docker/WORKSPACE.docs /workspace/WORKSPACE"
4545
env:
4646
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
4747
- name: Install dependencies

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ bazel-genfiles
55
bazel-out
66
bazel-testlogs
77
bazel-TRTorch
8+
bazel-trtorch-testing
89
third_party/pytorch
910
*.jit
1011
*.jit.pt
@@ -37,4 +38,6 @@ bdist
3738
py/trtorch/_version.py
3839
py/wheelhouse
3940
py/.eggs
40-
notebooks/.ipynb_checkpoints/
41+
notebooks/.ipynb_checkpoints/
42+
*.cache
43+
tests/py/data

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ We use the PyTorch Slack for communication about core development, integration w
1616

1717
- Use the built in linting tools to ensure that your code matches the style guidelines
1818
```sh
19-
# C++ Linting (After installing clang-format)
19+
# C++ Linting (After installing clang-format [Version 9.0.0])
2020
# Print non-conforming sections of code
2121
bazel run //tools/linter:cpplint_diff -- //...
2222
# Modify code to conform with style guidelines

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ torch.jit.save(trt_ts_module, "trt_torchscript_module.ts")
7373
### Dependencies
7474
These are the following dependencies used to verify the testcases. TRTorch can work with other versions, but the tests are not guaranteed to pass.
7575

76-
- Bazel 3.7.0
77-
- Libtorch 1.7.x (built with CUDA 11.0)
78-
- CUDA 11.0 (10.2 on Jetson)
79-
- cuDNN 8
80-
- TensorRT 7.2
76+
- Bazel 4.0.0
77+
- Libtorch 1.8.0 (built with CUDA 11.1)
78+
- CUDA 11.1 (10.2 on Jetson)
79+
- cuDNN 8.1
80+
- TensorRT 7.2.3
8181

8282
## Prebuilt Binaries and Wheel files
8383

WORKSPACE

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ git_repository(
3535
# CUDA should be installed on the system locally
3636
new_local_repository(
3737
name = "cuda",
38-
path = "/usr/local/cuda-11.0/",
38+
path = "/usr/local/cuda-11.1/",
3939
build_file = "@//third_party/cuda:BUILD",
4040
)
4141

@@ -53,16 +53,16 @@ http_archive(
5353
name = "libtorch",
5454
build_file = "@//third_party/libtorch:BUILD",
5555
strip_prefix = "libtorch",
56-
sha256 = "117f6dd65b7267839197397edd0b10fd2900b0f291e3e54b0b800caefc31bcb6",
57-
urls = ["https://download.pytorch.org/libtorch/cu110/libtorch-cxx11-abi-shared-with-deps-1.7.1%2Bcu110.zip"],
56+
sha256 = "62a2c06761c32576b30f5884240cf675b937945d929e4b13cc776de8d9c2236c",
57+
urls = ["https://download.pytorch.org/libtorch/cu111/libtorch-cxx11-abi-shared-with-deps-1.8.0%2Bcu111.zip"],
5858
)
5959

6060
http_archive(
6161
name = "libtorch_pre_cxx11_abi",
6262
build_file = "@//third_party/libtorch:BUILD",
6363
strip_prefix = "libtorch",
64-
sha256 = "c77f926afd55d7e860ec9c7abc992c25be77c89771c3ec6fcc13ea42f07d46df",
65-
urls = ["https://download.pytorch.org/libtorch/cu110/libtorch-shared-with-deps-1.7.1%2Bcu110.zip"],
64+
sha256 = "1c8b0c0883dd17f5ce952d42ec5f7f0cc7ceb370307535cee26a66c10419f1f6",
65+
urls = ["https://download.pytorch.org/libtorch/cu111/libtorch-shared-with-deps-1.8.0%2Bcu111.zip"],
6666
)
6767

6868
# Download these tarballs manually from the NVIDIA website
@@ -71,18 +71,18 @@ http_archive(
7171

7272
http_archive(
7373
name = "cudnn",
74-
urls = ["https://developer.nvidia.com/compute/machine-learning/cudnn/secure/8.0.5/11.0_20201106/cudnn-11.0-linux-x64-v8.0.5.39.tgz",],
74+
urls = ["https://developer.nvidia.com/compute/machine-learning/cudnn/secure/8.1.1.33/11.2_20210301/cudnn-11.2-linux-x64-v8.1.1.33.tgz",],
7575
build_file = "@//third_party/cudnn/archive:BUILD",
76-
sha256 = "4e16ee7895deb4a8b1c194b812ba49586ef7d26902051401d3717511898a9b73",
76+
sha256 = "98a8784e92862f20018d20c281b30d4a0cd951f93694f6433ccf4ae9c502ba6a",
7777
strip_prefix = "cuda"
7878
)
7979

8080
http_archive(
8181
name = "tensorrt",
82-
urls = ["https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/7.2.2/tars/TensorRT-7.2.2.3.Ubuntu-18.04.x86_64-gnu.cuda-11.0.cudnn8.0.tar.gz",],
82+
urls = ["https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/7.2.3/tars/TensorRT-7.2.3.4.Ubuntu-18.04.x86_64-gnu.cuda-11.1.cudnn8.1.tar.gz",],
8383
build_file = "@//third_party/tensorrt/archive:BUILD",
84-
strip_prefix = "TensorRT-7.2.2.3",
85-
sha256 = "b5c325e38e1d92ce1ce92ca8b54ede9c224bf128c9a53eb0b9022f1ee4313ee0"
84+
strip_prefix = "TensorRT-7.2.3.4",
85+
sha256 = "d3a1f478e304b48878604fac70ce7920fece71f9cac62f925c9c59c197f5d087"
8686
)
8787

8888
####################################################################################

core/conversion/conversionctx/ConversionCtx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct BuilderSettings {
2828
bool refit = false;
2929
bool debug = false;
3030
bool strict_types = false;
31+
bool truncate_long_and_double = false;
3132
Device device;
3233
nvinfer1::EngineCapability capability = nvinfer1::EngineCapability::kDEFAULT;
3334
nvinfer1::IInt8Calibrator* calibrator = nullptr;

core/conversion/converters/impl/batch_norm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ auto batch_norm_registrations TRTORCH_UNUSED = RegisterNodeConversionPatterns().
4343
auto should_unpack = util::toVec(orig_shape).size() < 4;
4444
if (should_unpack) {
4545
// expand spatial dims from 1D to 2D
46-
auto new_shape = util::toDimsPad(util::toVec(orig_shape), 4);
46+
auto new_shape = util::toDimsTailPad(util::toVec(orig_shape), 4);
4747
LOG_DEBUG(
4848
"Input shape is less than 4D got: "
4949
<< orig_shape << ", inserting shuffle layer to reshape to 4D tensor shape: " << new_shape);

core/conversion/converters/impl/plugins/interpolate_plugin.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ int InterpolatePlugin::enqueue(
254254
cudaStream_t stream) {
255255
#if NV_TENSORRT_MAJOR < 7 || (NV_TENSORRT_MAJOR == 7 && NV_TENSORRT_MINOR < 1)
256256
at::Tensor input = at::from_blob((void*)inputs[0], util::toVec(inputDesc->dims), [](void*) {}, tensor_options_);
257-
at::Tensor output = at::from_blob(outputs[0], util::volume(outputDesc->dims), [](void*) {}, tensor_options_);
257+
at::Tensor output = at::from_blob(
258+
outputs[0], util::volume(outputDesc->dims), [](void*) {}, tensor_options_);
258259

259260
at::cuda::CUDAStream torch_stream = at::cuda::getStreamFromPool();
260261
at::cuda::CUDAStreamGuard torch_guard(torch_stream);

core/conversion/converters/impl/select.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ bool add_split(ConversionCtx* ctx, const torch::jit::Node* n, args& args, bool s
1818
auto in = args[0].ITensor();
1919
auto axis = args[2].unwrapToInt();
2020
auto inDimSize = in->getDimensions().d[axis];
21-
auto numOutputs = 1;
21+
auto numOutputs = 1, numRemainder = 0;
2222
std::vector<int64_t> sizes;
2323

2424
if (split_list) {
@@ -27,10 +27,13 @@ bool add_split(ConversionCtx* ctx, const torch::jit::Node* n, args& args, bool s
2727
} else {
2828
auto split_size = args[1].unwrapToInt();
2929
numOutputs = inDimSize / split_size;
30-
if (numOutputs == 1) {
30+
numRemainder = inDimSize % split_size;
31+
for (int64_t i = 0; i < numOutputs; i++) {
3132
sizes.push_back(split_size);
32-
} else {
33-
sizes = std::vector<int64_t>(numOutputs, 1);
33+
}
34+
if (numRemainder) {
35+
numOutputs += 1;
36+
sizes.push_back(numRemainder);
3437
}
3538
}
3639

@@ -42,7 +45,7 @@ bool add_split(ConversionCtx* ctx, const torch::jit::Node* n, args& args, bool s
4245
list.reserve(numOutputs);
4346

4447
int start_idx = 0;
45-
for (int i = 0; i < numOutputs; i++) {
48+
for (int64_t i = 0; i < numOutputs; i++) {
4649
at::Tensor indices = torch::arange(start_idx, start_idx + sizes[i], 1).to(torch::kI32);
4750
auto indicesTensor = tensor_to_const(ctx, indices);
4851

@@ -68,7 +71,9 @@ auto select_registrations TRTORCH_UNUSED =
6871
.pattern({"aten::select.int(Tensor(a) self, int dim, int index) -> (Tensor(a))",
6972
[](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
7073
auto in = args[0].ITensor();
74+
auto maxDim = static_cast<int64_t>(in->getDimensions().nbDims);
7175
auto axis = args[1].unwrapToInt();
76+
axis = axis < 0 ? axis + maxDim : axis;
7277
auto ind = (int32_t)args[2].unwrapToInt();
7378

7479
// index to access needs to be an at::Tensor
@@ -89,7 +94,7 @@ auto select_registrations TRTORCH_UNUSED =
8994
// IShuffleLayer removes redundant dimensions
9095
auto shuffle_layer = ctx->net->addShuffle(*gather_out);
9196
TRTORCH_CHECK(shuffle_layer, "Unable to create shuffle layer from node: " << *n);
92-
shuffle_layer->setReshapeDimensions(util::unpadDims(gather_out->getDimensions()));
97+
shuffle_layer->setReshapeDimensions(util::squeezeDims(gather_out->getDimensions(), axis));
9398
shuffle_layer->setName(util::node_info(n).c_str());
9499
auto shuffle_out = shuffle_layer->getOutput(0);
95100

@@ -174,9 +179,11 @@ auto select_registrations TRTORCH_UNUSED =
174179
{"aten::embedding(Tensor weight, Tensor indices, int padding_idx=-1, bool scale_grad_by_freq=False, bool sparse=False) -> (Tensor)",
175180
[](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
176181
auto embeddingTensor = args[0].ITensorOrFreeze(ctx);
177-
auto indicesTensor = args[1].ITensor();
182+
auto indicesTensor = args[1].ITensorOrFreeze(ctx);
178183
// Set datatype for indices tensor to INT32
179-
indicesTensor->setType(nvinfer1::DataType::kINT32);
184+
auto identity = ctx->net->addIdentity(*indicesTensor);
185+
identity->setOutputType(0, nvinfer1::DataType::kINT32);
186+
indicesTensor = identity->getOutput(0);
180187

181188
// IGatherLayer takes in input tensor, the indices, and the axis of input tensor to take indices from
182189
auto gather_layer = ctx->net->addGather(*embeddingTensor, *indicesTensor, 0);

0 commit comments

Comments
 (0)