Skip to content

Commit 4ed2aac

Browse files
authored
Merge pull request #1320 from pytorch/master
Update release
2 parents 9e86efb + 81f2a5c commit 4ed2aac

File tree

116 files changed

+1148
-177
lines changed

Some content is hidden

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

116 files changed

+1148
-177
lines changed

.circleci/config.yml

+297-20
Large diffs are not rendered by default.

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ torch.jit.save(trt_ts_module, "trt_torchscript_module.ts") # save the TRT embedd
113113
These are the following dependencies used to verify the testcases. Torch-TensorRT can work with other versions, but the tests are not guaranteed to pass.
114114

115115
- Bazel 5.2.0
116-
- Libtorch 1.12.0 (built with CUDA 11.3)
117-
- CUDA 11.3
116+
- Libtorch 1.12.1 (built with CUDA 11.6)
117+
- CUDA 11.6
118118
- cuDNN 8.4.1
119-
- TensorRT 8.4.1.5
119+
- TensorRT 8.4.3.1
120120

121121
## Prebuilt Binaries and Wheel files
122122

WORKSPACE

+7-7
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ new_local_repository(
5656
http_archive(
5757
name = "libtorch",
5858
build_file = "@//third_party/libtorch:BUILD",
59-
sha256 = "80f089939de20e68e3fcad4dfa72a26c8bf91b5e77b11042f671f39ebac35865",
59+
sha256 = "5a392132fbff9db1482eae72a30f74b09f53a47edf8305fe9688d4ce7ddb0b6b",
6060
strip_prefix = "libtorch",
61-
urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-cxx11-abi-shared-with-deps-1.12.0%2Bcu113.zip"],
61+
urls = ["https://download.pytorch.org/libtorch/cu116/libtorch-cxx11-abi-shared-with-deps-1.12.1%2Bcu116.zip"],
6262
)
6363

6464
http_archive(
6565
name = "libtorch_pre_cxx11_abi",
6666
build_file = "@//third_party/libtorch:BUILD",
67-
sha256 = "8e35371403f7052d9e9b43bcff383980dbde4df028986dc1dab539953481d55f",
67+
sha256 = "5e044cc56a29cd4f3a7198c0fe5b2f0fa8f4c38cd71a0491274b6a914e8f24a7",
6868
strip_prefix = "libtorch",
69-
urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-shared-with-deps-1.12.0%2Bcu113.zip"],
69+
urls = ["https://download.pytorch.org/libtorch/cu116/libtorch-shared-with-deps-1.12.1%2Bcu116.zip"],
7070
)
7171

7272
# Download these tarballs manually from the NVIDIA website
@@ -86,10 +86,10 @@ http_archive(
8686
http_archive(
8787
name = "tensorrt",
8888
build_file = "@//third_party/tensorrt/archive:BUILD",
89-
sha256 = "8107861af218694130f170e071f49814fa3e27f1386ce7cb6d807ac05a7fcf0e",
90-
strip_prefix = "TensorRT-8.4.1.5",
89+
sha256 = "8d7c2085c1639dcc73875048c23598a8526ce3089136876e31d90258e49e4f61",
90+
strip_prefix = "TensorRT-8.4.3.1",
9191
urls = [
92-
"https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/8.4.1/tars/tensorrt-8.4.1.5.linux.x86_64-gnu.cuda-11.6.cudnn8.4.tar.gz",
92+
"https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/8.4.3/tars/tensorrt-8.4.3.1.linux.x86_64-gnu.cuda-11.6.cudnn8.4.tar.gz",
9393
],
9494
)
9595

core/conversion/converters/impl/expand.cpp

+110
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,116 @@ auto expand_registrations TORCHTRT_UNUSED =
282282
auto out = ctx->AssociateValueAndTensor(n->outputs()[0], in);
283283

284284
LOG_DEBUG("Repeat layer output tensor shape: " << out->getDimensions());
285+
return true;
286+
}})
287+
.pattern(
288+
{"aten::repeat_interleave.self_int(Tensor self, int repeats, int? dim=None, *, int? output_size=None) -> (Tensor)",
289+
[](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
290+
auto self = args[0].ITensorOrFreeze(ctx);
291+
auto repeats = args[1].unwrapToScalar().to<int>();
292+
293+
auto input_shape = self->getDimensions();
294+
295+
int dim;
296+
if (args[2].IValue()->isNone()) {
297+
dim = 0;
298+
299+
// Flatten self tensor
300+
int size;
301+
if (ctx->input_is_dynamic) {
302+
// Set size to -1 if input is dynamic
303+
size = -1;
304+
} else {
305+
size = 1;
306+
for (int i = 0; i < input_shape.nbDims; i++) {
307+
size *= input_shape.d[i];
308+
}
309+
}
310+
auto flatten = ctx->net->addShuffle(*self);
311+
TORCHTRT_CHECK(flatten, "Unable to create shuffle layer from node: " << *n);
312+
flatten->setReshapeDimensions(util::toDims(std::vector<int64_t>({size})));
313+
self = flatten->getOutput(0);
314+
input_shape = self->getDimensions();
315+
} else {
316+
dim = args[2].unwrapToScalar().to<int>();
317+
}
318+
319+
if (ctx->input_is_dynamic) {
320+
int dynamic_dims = 0;
321+
for (int idx = 0; idx < input_shape.nbDims; idx++) {
322+
if (input_shape.d[idx] == -1) {
323+
dynamic_dims++;
324+
}
325+
}
326+
327+
if (dynamic_dims > 1) {
328+
TORCHTRT_THROW_ERROR(
329+
"Repeat_interleave is currently not supported when target shape contains more than one dynamic dimension");
330+
}
331+
}
332+
333+
// Insert singleton dimension after desired repeat dimension
334+
std::vector<int64_t> repeat_shape_vec;
335+
for (int j = 0; j < input_shape.nbDims; j++) {
336+
repeat_shape_vec.push_back(input_shape.d[j]);
337+
if (j == dim) {
338+
repeat_shape_vec.push_back(1);
339+
}
340+
}
341+
auto expand = ctx->net->addShuffle(*self);
342+
TORCHTRT_CHECK(expand, "Unable to create shuffle layer from node: " << *n);
343+
auto repeat_shape_dims = util::toDims(repeat_shape_vec);
344+
expand->setReshapeDimensions(repeat_shape_dims);
345+
346+
// Expand on newly created singleton dimension
347+
repeat_shape_dims.d[dim + 1] = repeats;
348+
std::vector<int64_t> start_vec(repeat_shape_dims.nbDims, 0);
349+
auto start_dims = util::toDims(start_vec);
350+
351+
std::vector<int64_t> strides_vec(repeat_shape_dims.nbDims, 1);
352+
strides_vec[dim + 1] = 0;
353+
auto strides_dims = util::toDims(strides_vec);
354+
355+
auto slice = ctx->net->addSlice(*expand->getOutput(0), start_dims, repeat_shape_dims, strides_dims);
356+
357+
if (ctx->input_is_dynamic) {
358+
auto start_tensor = tensor_to_const(ctx, torch::tensor(start_vec, torch::kInt32));
359+
360+
auto expand_output_shape = ctx->net->addShape(*expand->getOutput(0))->getOutput(0);
361+
std::vector<int64_t> repeat_const_vec(repeat_shape_dims.nbDims, 1);
362+
repeat_const_vec[dim + 1] = repeats;
363+
auto repeat_const = tensor_to_const(ctx, torch::tensor(repeat_const_vec, torch::kInt32));
364+
auto repeat_shape_tensor =
365+
ctx->net
366+
->addElementWise(*expand_output_shape, *repeat_const, nvinfer1::ElementWiseOperation::kPROD)
367+
->getOutput(0);
368+
369+
auto strides_tensor = tensor_to_const(ctx, torch::tensor(strides_vec, torch::kInt32));
370+
slice->setInput(1, *start_tensor);
371+
slice->setInput(2, *repeat_shape_tensor);
372+
slice->setInput(3, *strides_tensor);
373+
}
374+
375+
// Collapse repeated dimension back into desired dimension
376+
std::vector<int64_t> collapse_shape_vec;
377+
for (int k = 0; k < repeat_shape_dims.nbDims; k++) {
378+
if (k == dim) {
379+
int64_t collapse_dim = repeat_shape_dims.d[k] * repeat_shape_dims.d[++k];
380+
// Set dim size to -1 if repeat is being done on dynamic dim
381+
collapse_dim = std::max(collapse_dim, (int64_t)-1);
382+
collapse_shape_vec.push_back(collapse_dim);
383+
} else {
384+
collapse_shape_vec.push_back(repeat_shape_dims.d[k]);
385+
}
386+
}
387+
auto collapse = ctx->net->addShuffle(*slice->getOutput(0));
388+
TORCHTRT_CHECK(collapse, "Unable to create shuffle layer from node: " << *n);
389+
collapse->setReshapeDimensions(util::toDims(collapse_shape_vec));
390+
391+
collapse->setName(util::node_info(n).c_str());
392+
auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], collapse->getOutput(0));
393+
LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
394+
285395
return true;
286396
}});
287397

0 commit comments

Comments
 (0)