Skip to content

Update release branch with latest test fixes #1339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 49 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
46961d9
chore: additional options for perf_run tool
dheerajperi May 31, 2022
a13607a
Merge branch 'master' into perf_changes
peri044 Jul 26, 2022
7779b50
feat: Add fx2trt backend and revamp current perf utility to accept CL…
peri044 Jul 27, 2022
6cbf600
Merge branch 'master' into perf_changes
peri044 Aug 2, 2022
d108f87
chore: Refactor fx2trt functionality
peri044 Aug 3, 2022
e92a813
chore: Fix fp16 functionality for fx2trt backend
peri044 Aug 4, 2022
6a98dec
chore: rebase
peri044 Aug 9, 2022
2925c8a
chore: refactor
peri044 Aug 10, 2022
46d0e86
chore: minor change
peri044 Aug 10, 2022
f8285ba
refactor: Refactor perf_run and add internal benchmark scripts
peri044 Aug 11, 2022
7461a24
Merge branch 'master' into perf_changes
peri044 Aug 11, 2022
561c339
chore : minor refactor
peri044 Aug 11, 2022
66573fc
Merge branch 'master' into perf_changes
peri044 Aug 11, 2022
5bf2f4a
chore: Apply precommit tooling
peri044 Aug 11, 2022
dd3af24
chore: Fix data loader issues and nox file paths
peri044 Aug 17, 2022
bfae556
chore: Fix merge conflicts
peri044 Aug 20, 2022
3a14f23
chore: rebase and minor changes
peri044 Aug 20, 2022
d5dbc4d
chore: Fix reporting to a file setting
peri044 Aug 20, 2022
e374eb1
Update lower.py (#1324)
Aug 30, 2022
2c55974
docs: [Automated] Regenerating documenation for e374eb1
Aug 30, 2022
5756169
refactor: Refactor testing to use cosine similarity, remove redundanc…
peri044 Aug 31, 2022
c6f3103
chore: move to cosine similarity comparison
peri044 Aug 31, 2022
beeac7c
refactor: Refactor nox file testing
peri044 Sep 1, 2022
7e6b36c
chore: add missing scripts
peri044 Sep 1, 2022
ed75e9d
chore: Linter fixes
peri044 Sep 1, 2022
7245727
fix!: Fixed Windows compilation failures
andi4191 Sep 1, 2022
a1a4786
Merge pull request #1330 from pytorch/anuragd/fix_windows_compilation
narendasan Sep 1, 2022
3da78e9
chore: Minor fix
peri044 Sep 1, 2022
0ca049f
chore: use rn18 instead of rn50
peri044 Sep 1, 2022
2af5942
docs: [Automated] Regenerating documenation for a1a4786
Sep 1, 2022
c864096
chore: Add cpp tests with cosine sim
peri044 Sep 1, 2022
8d8cbfd
chore: linter fixes
peri044 Sep 1, 2022
9db2852
[feat] Add support for argmax and argmin (#1312)
mfeliz-cruise Sep 2, 2022
d1768aa
docs: [Automated] Regenerating documenation for 9db2852
Sep 2, 2022
13cc024
chore: Deepcopy other objects
peri044 Sep 6, 2022
749048c
fix: Fix deepcopy issues of PTQ calibrators
peri044 Sep 7, 2022
af20761
chore: linter fixes
peri044 Sep 7, 2022
00a1f03
chore: Adding a guideline to build on Windows platform (#1337)
andi4191 Sep 8, 2022
f16ac7b
docs: [Automated] Regenerating documenation for 00a1f03
Sep 8, 2022
2186177
chore: minor fixes
peri044 Sep 8, 2022
3b45c80
chore: Linter fixes
peri044 Sep 8, 2022
7142c82
Merge pull request #1281 from pytorch/data_loader
peri044 Sep 8, 2022
77543a0
chore: Linter fixes
peri044 Sep 8, 2022
1efe4b1
Merge pull request #1254 from pytorch/perf_changes
peri044 Sep 8, 2022
99db0cd
docs: [Automated] Regenerating documenation for 1efe4b1
Sep 8, 2022
10b9ecd
Merge pull request #1329 from pytorch/python_tests
peri044 Sep 8, 2022
b25738e
docs: [Automated] Regenerating documenation for 10b9ecd
Sep 8, 2022
096fd41
add support for aten::reciprocal(int) (#1308)
mfeliz-cruise Sep 8, 2022
5f4588e
docs: [Automated] Regenerating documenation for 096fd41
Sep 8, 2022
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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ commands:
mkdir -p /tmp/artifacts/test_results
cd tests/py
pytest --junitxml=/tmp/artifacts/test_results/api/api_test_results.xml api/
pytest --junitxml=/tmp/artifacts/test_results/models/models_test_results.xml models/
pytest --junitxml=/tmp/artifacts/test_results/integrations/integrations_test_results.xml integrations/
cd ~/project

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Set up Python 3.9.4
uses: actions/setup-python@v2
with:
python-version: 3.9.4
python-version: 3.9.4
- uses: actions/checkout@v2
with:
ref: ${{github.head_ref}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
pip3 install -r $GITHUB_WORKSPACE/.github/scripts/requirements.txt
pip3 install -r $GITHUB_WORKSPACE/requirements-dev.txt
- name: Lint C++
run: |
run: |
cd $GITHUB_WORKSPACE
python3 $GITHUB_WORKSPACE/.github/scripts/run_cpp_linter.py
env:
Expand Down
130 changes: 89 additions & 41 deletions core/conversion/converters/impl/max.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,95 @@ namespace conversion {
namespace converters {
namespace impl {
namespace {
auto max_registrations TORCHTRT_UNUSED = RegisterNodeConversionPatterns().pattern(
{"aten::max.dim(Tensor self, int dim, bool keepdim=False) -> (Tensor values, Tensor indices)",
[](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
auto self = args[0].ITensorOrFreeze(ctx);
auto dim = args[1].unwrapToInt();
auto keep_dims = args[2].unwrapToBool();
auto selfDim = util::toVec(self->getDimensions());
if (dim < 0) {
dim = selfDim.size() + dim;
}
uint32_t shiftDim = 1 << dim;
auto TopKOperation = nvinfer1::TopKOperation::kMAX;
auto topk_layer = ctx->net->addTopK(*self, TopKOperation, 1, shiftDim);
TORCHTRT_CHECK(topk_layer, "Unable to create max layer from node: " << *n);
auto topk_dims = util::toVec(topk_layer->getOutput(0)->getDimensions());

nvinfer1::ITensor* out0 = nullptr;
nvinfer1::ITensor* out1 = nullptr;
if (!keep_dims) {
if (topk_dims[dim] == 1) {
auto squeeze_layer = ctx->net->addShuffle(*topk_layer->getOutput(0));
squeeze_layer->setReshapeDimensions(util::squeezeDims(topk_layer->getOutput(0)->getDimensions(), dim));
TORCHTRT_CHECK(squeeze_layer, "Unable to create squeeze_layer layer from node: " << *n);
out0 = ctx->AssociateValueAndTensor(n->outputs()[0], squeeze_layer->getOutput(0));

auto squeeze_layer_indices = ctx->net->addShuffle(*topk_layer->getOutput(1));
squeeze_layer_indices->setReshapeDimensions(
util::squeezeDims(topk_layer->getOutput(1)->getDimensions(), dim));
TORCHTRT_CHECK(squeeze_layer_indices, "Unable to create squeeze_layer_indices layer from node: " << *n);
out1 = ctx->AssociateValueAndTensor(n->outputs()[1], squeeze_layer_indices->getOutput(0));
}
} else {
out0 = ctx->AssociateValueAndTensor(n->outputs()[0], topk_layer->getOutput(0));
out1 = ctx->AssociateValueAndTensor(n->outputs()[1], topk_layer->getOutput(1));
}

LOG_DEBUG("Output tensor(0) shape: " << out0->getDimensions());
LOG_DEBUG("Output tensor(1) shape: " << out1->getDimensions());

return true;
}});

bool min_max_dim(ConversionCtx* ctx, const torch::jit::Node* n, args& args, nvinfer1::TopKOperation topKOperation) {
auto self = args[0].ITensorOrFreeze(ctx);
auto dim = args[1].unwrapToInt();
auto keep_dims = args[2].unwrapToBool();
auto selfDim = util::toVec(self->getDimensions());
if (dim < 0) {
dim = selfDim.size() + dim;
}
uint32_t reduce_axes_mask = 1 << dim;
auto topk_layer = ctx->net->addTopK(*self, topKOperation, 1, reduce_axes_mask);
TORCHTRT_CHECK(topk_layer, "Unable to create topk layer from node: " << *n);
auto topk_dims = util::toVec(topk_layer->getOutput(0)->getDimensions());

nvinfer1::ITensor* out0 = nullptr;
nvinfer1::ITensor* out1 = nullptr;
if (!keep_dims) {
TORCHTRT_CHECK(topk_dims[dim] == 1, "Unexpected size in squeeze dimension. Expected: 1 Actual: " << topk_dims[dim]);
auto squeeze_layer = ctx->net->addShuffle(*topk_layer->getOutput(0));
squeeze_layer->setReshapeDimensions(util::squeezeDims(topk_layer->getOutput(0)->getDimensions(), dim));
TORCHTRT_CHECK(squeeze_layer, "Unable to create squeeze_layer layer from node: " << *n);
out0 = ctx->AssociateValueAndTensor(n->outputs()[0], squeeze_layer->getOutput(0));

auto squeeze_layer_indices = ctx->net->addShuffle(*topk_layer->getOutput(1));
squeeze_layer_indices->setReshapeDimensions(util::squeezeDims(topk_layer->getOutput(1)->getDimensions(), dim));
TORCHTRT_CHECK(squeeze_layer_indices, "Unable to create squeeze_layer_indices layer from node: " << *n);
out1 = ctx->AssociateValueAndTensor(n->outputs()[1], squeeze_layer_indices->getOutput(0));
} else {
out0 = ctx->AssociateValueAndTensor(n->outputs()[0], topk_layer->getOutput(0));
out1 = ctx->AssociateValueAndTensor(n->outputs()[1], topk_layer->getOutput(1));
}

LOG_DEBUG("Output tensor(0) shape: " << out0->getDimensions());
LOG_DEBUG("Output tensor(1) shape: " << out1->getDimensions());

return true;
}

bool arg_min_max(ConversionCtx* ctx, const torch::jit::Node* n, args& args, nvinfer1::TopKOperation topKOperation) {
auto self = args[0].ITensorOrFreeze(ctx);
auto dim = args[1].unwrapToInt();
auto keep_dims = args[2].unwrapToBool();
auto selfDim = util::toVec(self->getDimensions());
if (dim < 0) {
dim = selfDim.size() + dim;
}
uint32_t reduce_axes_mask = 1 << dim;
auto topk_layer = ctx->net->addTopK(*self, topKOperation, 1, reduce_axes_mask);
TORCHTRT_CHECK(topk_layer, "Unable to create topk layer from node: " << *n);
auto topk_dims = util::toVec(topk_layer->getOutput(0)->getDimensions());

nvinfer1::ITensor* out = nullptr;
if (!keep_dims) {
TORCHTRT_CHECK(topk_dims[dim] == 1, "Unexpected size in squeeze dimension. Expected: 1 Actual: " << topk_dims[dim]);
auto squeeze_layer_indices = ctx->net->addShuffle(*topk_layer->getOutput(1));
squeeze_layer_indices->setReshapeDimensions(util::squeezeDims(topk_layer->getOutput(1)->getDimensions(), dim));
TORCHTRT_CHECK(squeeze_layer_indices, "Unable to create squeeze_layer_indices layer from node: " << *n);
out = ctx->AssociateValueAndTensor(n->outputs()[0], squeeze_layer_indices->getOutput(0));
} else {
out = ctx->AssociateValueAndTensor(n->outputs()[0], topk_layer->getOutput(1));
}

LOG_DEBUG("Output tensor shape: " << out->getDimensions());

return true;
}

auto max_registrations TORCHTRT_UNUSED =
RegisterNodeConversionPatterns()
.pattern(
{"aten::max.dim(Tensor self, int dim, bool keepdim=False) -> (Tensor values, Tensor indices)",
[](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
return min_max_dim(ctx, n, args, nvinfer1::TopKOperation::kMAX);
}})
.pattern(
{"aten::min.dim(Tensor self, int dim, bool keepdim=False) -> (Tensor values, Tensor indices)",
[](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
return min_max_dim(ctx, n, args, nvinfer1::TopKOperation::kMIN);
}})
.pattern(
{"aten::argmax(Tensor self, int dim, bool keepdim=False) -> (Tensor)",
[](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
return arg_min_max(ctx, n, args, nvinfer1::TopKOperation::kMAX);
}})
.pattern(
{"aten::argmin(Tensor self, int dim, bool keepdim=False) -> (Tensor)",
[](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
return arg_min_max(ctx, n, args, nvinfer1::TopKOperation::kMIN);
}});
} // namespace
} // namespace impl
} // namespace converters
Expand Down
16 changes: 15 additions & 1 deletion core/conversion/converters/impl/unary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ auto abs_registration TORCHTRT_UNUSED = RegisterNodeConversionPatterns().pattern
}
}});

auto reciprocal_registration TORCHTRT_UNUSED = RegisterNodeConversionPatterns().pattern(
{"aten::reciprocal(Tensor self) -> Tensor", [](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
auto in = args[0].ITensorOrFreeze(ctx);
if (in->getType() == nvinfer1::DataType::kINT32) {
// pytorch implicitly casts to float for aten::reciprocal(int)
in = castITensor(ctx, in, nvinfer1::DataType::kFLOAT);
}
auto unary_layer = ctx->net->addUnary(*in, nvinfer1::UnaryOperation::kRECIP);
TORCHTRT_CHECK(unary_layer, "Unable to create recip layer from node: " << *n);
unary_layer->setName(util::node_info(n).c_str());
auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], unary_layer->getOutput(0));
LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
return true;
}});

#define convert(unary, trt_type) \
auto unary##_registrations TORCHTRT_UNUSED = RegisterNodeConversionPatterns().pattern( \
{"aten::" #unary "(Tensor self) -> Tensor", \
Expand All @@ -74,7 +89,6 @@ convert(sinh, kSINH);
convert(tan, kTAN);
convert(atan, kATAN);
convert(floor, kFLOOR);
convert(reciprocal, kRECIP);
convert(log, kLOG);
convert(ceil, kCEIL);
convert(sqrt, kSQRT);
Expand Down
2 changes: 1 addition & 1 deletion core/partitioning/shape_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void getSegmentsOutputByRunning(
}
if (cur_ivalue.toTensor().sizes().size() == 0) {
// handle Scalar types, which has sizes of []
input_shapes.push_back(util::toVec(util::toDims(c10::List<long int>({1}))));
input_shapes.push_back(util::toVec(util::toDims(c10::List<int64_t>({1}))));
} else {
input_shapes.push_back(util::toVec(util::toDims(cur_ivalue.toTensor().sizes())));
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/bin/torchtrtc/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bool unload_library(void* custom_lib) {
bool success = false;
#if defined(_WIN32)
// Returns status non-zero for success
success = FreeLibrary(custom_lib) ? true : false;
success = FreeLibrary((HMODULE)custom_lib) ? true : false;
#else
success = dlclose(custom_lib) ? false : true;
#endif
Expand Down
8 changes: 4 additions & 4 deletions cpp/include/torch_tensorrt/torch_tensorrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ class TensorFormat {
* signifying a static input shape or a set of three input shapes representing
* the min, optiminal and max input shapes allowed for the engine.
*/
struct TORCHTRT_API Input : torch::CustomClassHolder {
struct Input : torch::CustomClassHolder {
/// Minimum acceptable input size into the engine
std::vector<int64_t> min_shape;
/// Optimal input size into the engine (size optimized for given kernels accept any size in min max range)
Expand Down Expand Up @@ -520,7 +520,7 @@ struct TORCHTRT_API Input : torch::CustomClassHolder {
*
* This struct can either hold a complex inputs of shape or a flattened one,
*/
struct TORCHTRT_API GraphInputs {
struct GraphInputs {
torch::jit::IValue input_signature; // nested Input, full input spec
std::vector<Input> inputs; // flatten input spec
};
Expand Down Expand Up @@ -592,14 +592,14 @@ struct CompileSpec {
*
* @param inputs
*/
CompileSpec(std::vector<Input> inputs);
TORCHTRT_API CompileSpec(std::vector<Input> inputs);

/**
* @brief Construct a new Compile Spec object from IValue which represents the nesting of input tensors for a module.
*
* @param input_signature
*/
CompileSpec(torch::jit::IValue input_signature);
TORCHTRT_API CompileSpec(torch::jit::IValue input_signature);
// Defaults should reflect TensorRT defaults for BuilderConfig

/**
Expand Down
2 changes: 1 addition & 1 deletion docs/_cpp_api/classtorch__tensorrt_1_1DataType.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@


<div class="version">
master (1.2.0a0+51a991e)
master (1.2.0a0+096fd41)
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@


<div class="version">
master (1.2.0a0+51a991e)
master (1.2.0a0+096fd41)
</div>


Expand Down
2 changes: 1 addition & 1 deletion docs/_cpp_api/classtorch__tensorrt_1_1TensorFormat.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@


<div class="version">
master (1.2.0a0+51a991e)
master (1.2.0a0+096fd41)
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@


<div class="version">
master (1.2.0a0+51a991e)
master (1.2.0a0+096fd41)
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@


<div class="version">
master (1.2.0a0+51a991e)
master (1.2.0a0+096fd41)
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@


<div class="version">
master (1.2.0a0+51a991e)
master (1.2.0a0+096fd41)
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@


<div class="version">
master (1.2.0a0+51a991e)
master (1.2.0a0+096fd41)
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@


<div class="version">
master (1.2.0a0+51a991e)
master (1.2.0a0+096fd41)
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@


<div class="version">
master (1.2.0a0+51a991e)
master (1.2.0a0+096fd41)
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@


<div class="version">
master (1.2.0a0+51a991e)
master (1.2.0a0+096fd41)
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@


<div class="version">
master (1.2.0a0+51a991e)
master (1.2.0a0+096fd41)
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@


<div class="version">
master (1.2.0a0+51a991e)
master (1.2.0a0+096fd41)
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@


<div class="version">
master (1.2.0a0+51a991e)
master (1.2.0a0+096fd41)
</div>


Expand Down
2 changes: 1 addition & 1 deletion docs/_cpp_api/dir_cpp.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@


<div class="version">
master (1.2.0a0+51a991e)
master (1.2.0a0+096fd41)
</div>


Expand Down
2 changes: 1 addition & 1 deletion docs/_cpp_api/dir_cpp_include.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@


<div class="version">
master (1.2.0a0+51a991e)
master (1.2.0a0+096fd41)
</div>


Expand Down
2 changes: 1 addition & 1 deletion docs/_cpp_api/dir_cpp_include_torch_tensorrt.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@


<div class="version">
master (1.2.0a0+51a991e)
master (1.2.0a0+096fd41)
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@


<div class="version">
master (1.2.0a0+51a991e)
master (1.2.0a0+096fd41)
</div>


Expand Down
Loading