Skip to content

Commit 24c3a22

Browse files
committed
refactor: Apply linting
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
1 parent b3589c5 commit 24c3a22

File tree

8 files changed

+18
-21
lines changed

8 files changed

+18
-21
lines changed

core/compiler.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ torch::jit::script::Module CompileGraphWithFallback(const torch::jit::script::Mo
213213
LOG_INFO(*g << "(LoweringGraph)\n");
214214

215215
// segment the graph and convert segmented TensorRT block
216-
auto segmented_blocks =
217-
partitioning::Partition(g, convert_cfg.input_ranges, cfg.partition_info);
216+
auto segmented_blocks = partitioning::Partition(g, convert_cfg.input_ranges, cfg.partition_info);
218217
if (segmented_blocks.size() == 1 && segmented_blocks[0].target() == partitioning::SegmentedBlock::kTorch) {
219218
return mod;
220219
}

core/conversion/conversion.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ void AddLayer(ConversionCtx* ctx, const torch::jit::Node* n) {
118118
<< "please report this error to https://www.github.com/NVIDIA/TRTorch/issues");
119119
}
120120

121-
void AddInputs(ConversionCtx* ctx, at::ArrayRef<const torch::jit::Value*> inputs, std::vector<ir::InputRange>& input_dims) {
121+
void AddInputs(
122+
ConversionCtx* ctx,
123+
at::ArrayRef<const torch::jit::Value*> inputs,
124+
std::vector<ir::InputRange>& input_dims) {
122125
std::vector<const torch::jit::Value*> input_tensors;
123126
for (auto in : inputs) {
124127
// Disregarding inputs that are not tensors

core/conversion/var/Var.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ nvinfer1::ITensor* Var::ITensorOrFreeze(ConversionCtx* ctx) {
8989
if (isIValue()) {
9090
LOG_DEBUG(ctx->logger, "Found IValue containing object of type " << *(ptr_.ivalue->type()));
9191
}
92-
92+
9393
TRTORCH_CHECK(
9494
isITensor() || (isIValue() && (ptr_.ivalue->isTensor() || ptr_.ivalue->isCustomClass())),
9595
"Requested either IValue containing a Tensor, or ITensor, however Var type is " << type_name());
@@ -100,8 +100,10 @@ nvinfer1::ITensor* Var::ITensorOrFreeze(ConversionCtx* ctx) {
100100
if (ptr_.ivalue->isTensor()) {
101101
auto weights = converters::Weights();
102102
auto tensor = ptr_.ivalue->toTensor();
103-
if ((tensor.scalar_type() == at::kLong || tensor.scalar_type() == at::kDouble) && !ctx->settings.truncate_long_and_double) {
104-
TRTORCH_THROW_ERROR("Unable to freeze tensor of type Int64/Float64 into constant layer, try to compile model with truncate_long_and_double enabled");
103+
if ((tensor.scalar_type() == at::kLong || tensor.scalar_type() == at::kDouble) &&
104+
!ctx->settings.truncate_long_and_double) {
105+
TRTORCH_THROW_ERROR(
106+
"Unable to freeze tensor of type Int64/Float64 into constant layer, try to compile model with truncate_long_and_double enabled");
105107
} else if (tensor.scalar_type() == at::kLong && ctx->settings.truncate_long_and_double) {
106108
weights = converters::Weights(ctx, tensor.toType(at::kInt));
107109
LOG_WARNING("Truncating weight (constant in the graph) from Int64 to Int32");
@@ -111,7 +113,7 @@ nvinfer1::ITensor* Var::ITensorOrFreeze(ConversionCtx* ctx) {
111113
} else {
112114
weights = converters::Weights(ctx, tensor);
113115
}
114-
116+
115117
auto const_layer = ctx->net->addConstant(weights.shape, weights.data);
116118
TRTORCH_CHECK(const_layer, "Unable to freeze tensor into constant layer");
117119
out = const_layer->getOutput(0);

core/partitioning/PartitionInfo.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#pragma once
22

33
#include <cstdint>
4-
#include <vector>
54
#include <string>
5+
#include <vector>
66

77
namespace trtorch {
88
namespace core {
99
namespace partitioning {
1010

1111
struct PartitionInfo {
12-
bool enabled = false;
13-
uint64_t min_block_size = 1;
14-
std::vector<std::string> forced_fallback_operators;
12+
bool enabled = false;
13+
uint64_t min_block_size = 1;
14+
std::vector<std::string> forced_fallback_operators;
1515
};
1616

1717
std::ostream& operator<<(std::ostream& os, const PartitionInfo& s);

core/partitioning/SegmentedBlock.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ torch::jit::Node* SegmentedBlock::cloneNode(torch::jit::Node* node) {
3838
return new_node;
3939
}
4040

41-
42-
4341
} // namespace partitioning
4442
} // namespace core
4543
} // namespace trtorch

core/partitioning/SegmentedBlock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,6 @@ struct SegmentedBlock {
122122
std::unordered_map<torch::jit::Value*, torch::jit::Value*> old_to_new_;
123123
};
124124

125-
} // namespace ir
125+
} // namespace partitioning
126126
} // namespace core
127127
} // namespace trtorch

core/partitioning/partitioning.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,7 @@ void registerSegmentsOutputs(PartitionedGraph& segmented_blocks, std::shared_ptr
153153
return;
154154
}
155155

156-
std::vector<SegmentedBlock> segment_graph(
157-
std::shared_ptr<torch::jit::Graph> g,
158-
const PartitionInfo& partition_info) {
156+
std::vector<SegmentedBlock> segment_graph(std::shared_ptr<torch::jit::Graph> g, const PartitionInfo& partition_info) {
159157
auto min_block_size = partition_info.min_block_size;
160158
std::unordered_set<std::string> forced_fallback_operators(
161159
partition_info.forced_fallback_operators.begin(), partition_info.forced_fallback_operators.end());
@@ -199,12 +197,10 @@ std::vector<SegmentedBlock> segment_graph(
199197
return std::move(segmented_blocks);
200198
}
201199

202-
203200
std::vector<SegmentedBlock> Partition(
204201
std::shared_ptr<torch::jit::Graph> g,
205202
std::vector<ir::InputRange>& input_ranges,
206203
const PartitionInfo& partition_info) {
207-
208204
LOG_DEBUG(partition_info);
209205
// segment lowering global graph into blocks
210206
std::vector<SegmentedBlock> segmented_blocks = segment_graph(g, partition_info);

core/partitioning/shape_analysis.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#include "core/partitioning/SegmentedBlock.h"
21
#include "core/ir/ir.h"
3-
2+
#include "core/partitioning/SegmentedBlock.h"
43

54
namespace trtorch {
65
namespace core {

0 commit comments

Comments
 (0)