-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(//core/partitioning): Reorganizing partitioning deps
Reorganizing the partitioning dependencies so that there is a clearer relationship between major compiler modules Signed-off-by: Naren Dasan <naren@narendasan.com> Signed-off-by: Naren Dasan <narens@nvidia.com>
- Loading branch information
1 parent
6e96289
commit fb1a299
Showing
22 changed files
with
249 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
config_setting( | ||
name = "use_pre_cxx11_abi", | ||
values = { | ||
"define": "abi=pre_cxx11_abi", | ||
} | ||
) | ||
|
||
cc_library( | ||
name = "ir", | ||
hdrs = [ | ||
"ir.h" | ||
], | ||
srcs = [ | ||
"InputRange.cpp", | ||
], | ||
deps = [ | ||
"@tensorrt//:nvinfer", | ||
"//core/util:prelude", | ||
] + select({ | ||
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"], | ||
"//conditions:default": ["@libtorch//:libtorch"], | ||
}), | ||
) | ||
|
||
load("@rules_pkg//:pkg.bzl", "pkg_tar") | ||
|
||
pkg_tar( | ||
name = "include", | ||
package_dir = "core/ir/", | ||
srcs = [ | ||
"ir.h", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include "core/ir/ir.h" | ||
#include "core/util/prelude.h" | ||
|
||
namespace trtorch { | ||
namespace core { | ||
namespace ir { | ||
|
||
InputRange::InputRange(std::vector<int64_t> d) { | ||
if (d.size() > 5) { | ||
LOG_WARNING("Verify that this dim size is accepted"); | ||
} | ||
|
||
opt = util::toDims(d); | ||
min = util::toDims(d); | ||
max = util::toDims(d); | ||
input_shape = util::toDims(d); | ||
input_is_dynamic = false; | ||
} | ||
|
||
InputRange::InputRange(std::vector<int64_t> min_shape, std::vector<int64_t> opt_shape, std::vector<int64_t> max_shape) { | ||
if (min_shape.size() > 5 || opt_shape.size() > 5 || max_shape.size() > 5) { | ||
LOG_WARNING("Verify that this dim size is accepted"); | ||
} | ||
|
||
std::set<size_t> sizes; | ||
sizes.insert(min_shape.size()); | ||
sizes.insert(opt_shape.size()); | ||
sizes.insert(max_shape.size()); | ||
|
||
if (sizes.size() != 1) { | ||
LOG_ERROR( | ||
"Expected all input sizes have the same dimensions, but found dimensions: min(" | ||
<< min_shape.size() << "), opt(" << opt_shape.size() << "), max(" << max_shape.size() << ")"); | ||
} | ||
|
||
min = util::toDims(min_shape); | ||
opt = util::toDims(opt_shape); | ||
max = util::toDims(max_shape); | ||
|
||
std::vector<int64_t> dyn_shape; | ||
for (size_t i = 0; i < opt_shape.size(); i++) { | ||
std::set<uint64_t> dim; | ||
dim.insert(min_shape[i]); | ||
dim.insert(opt_shape[i]); | ||
dim.insert(max_shape[i]); | ||
if (dim.size() != 1) { | ||
dyn_shape.push_back(-1); | ||
input_is_dynamic = true; | ||
} else { | ||
dyn_shape.push_back(opt_shape[i]); | ||
} | ||
} | ||
|
||
input_shape = util::toDims(dyn_shape); | ||
} | ||
|
||
} // namespace ir | ||
} // namespace core | ||
} // namespace trtorch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include "NvInfer.h" | ||
|
||
namespace trtorch { | ||
namespace core { | ||
namespace ir { | ||
|
||
struct InputRange { | ||
nvinfer1::Dims min; | ||
nvinfer1::Dims max; | ||
nvinfer1::Dims opt; | ||
nvinfer1::Dims input_shape; | ||
bool input_is_dynamic = false; | ||
// Should we restrict to unsigned? | ||
InputRange(std::vector<int64_t> d); | ||
InputRange(std::vector<int64_t> min_shape, std::vector<int64_t> opt_shape, std::vector<int64_t> max_shape); | ||
}; | ||
|
||
} // namespace ir | ||
} // namespace core | ||
} // namespace trtorch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <vector> | ||
#include <string> | ||
|
||
namespace trtorch { | ||
namespace core { | ||
namespace partitioning { | ||
|
||
struct PartitionInfo { | ||
bool enabled = false; | ||
uint64_t min_block_size = 1; | ||
std::vector<std::string> forced_fallback_operators; | ||
}; | ||
|
||
} // namespace partitioning | ||
} // namespace core | ||
} // namespace trtorch |
Oops, something went wrong.