Skip to content

chore: Fix centralized partititoning #1367

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 4 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ pkg_tar(
"//core/lowering:include",
"//core/lowering/passes:include",
"//core/partitioning:include",
"//core/partitioning/segmentedblock:include",
"//core/partitioning/partitioninginfo:include",
"//core/partitioning/partitioningctx:include",
"//core/plugins:impl_include",
"//core/plugins:include",
"//core/runtime:include",
Expand Down
3 changes: 2 additions & 1 deletion core/partitioning/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ add_library(${lib_name} OBJECT)
set(CXX_SRCS
"${CMAKE_CURRENT_SOURCE_DIR}/partitioning.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/shape_analysis.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/stitching.cpp"
)

set(HEADER_FILES
Expand Down Expand Up @@ -36,4 +37,4 @@ add_subdirectory(partitioningctx)
add_subdirectory(partitioninginfo)
add_subdirectory(segmentedblock)

install(FILES ${HEADER_FILES} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/torch_tensorrt/core/partitioning")
install(FILES ${HEADER_FILES} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/torch_tensorrt/core/partitioning")
2 changes: 0 additions & 2 deletions core/partitioning/shape_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ std::unordered_map<const torch::jit::Value*, torch::jit::IValue> generateRandomI

for (auto& input : inputs) {
if (input.first->type()->kind() == torch::jit::TypeKind::ListType) {
// create list
std::vector<torch::jit::IValue> list;
c10::TypePtr elementType = c10::TensorType::get();
auto generic_list = c10::impl::GenericList(elementType);
for (size_t i = 0; i < input.second.size(); i++) {
Expand Down
3 changes: 3 additions & 0 deletions py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ def run(self):
"include/torch_tensorrt/core/lowering/*.h",
"include/torch_tensorrt/core/lowering/passes/*.h",
"include/torch_tensorrt/core/partitioning/*.h",
"include/torch_tensorrt/core/partitioning/segmentedblock/*.h",
"include/torch_tensorrt/core/partitioning/partitioninginfo/*.h",
"include/torch_tensorrt/core/partitioning/partitioningctx/*.h",
"include/torch_tensorrt/core/plugins/*.h",
"include/torch_tensorrt/core/plugins/impl/*.h",
"include/torch_tensorrt/core/runtime/*.h",
Expand Down
4 changes: 2 additions & 2 deletions tests/core/conversion/converters/test_topk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TEST(Converters, ATenTopKConvertsCorrectly) {
auto trt_results = torch_tensorrt::tests::util::RunGraphEngine(g, params, {in});

ASSERT_TRUE(
torch_tensorrt::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6));
torch_tensorrt::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 8e-5));
ASSERT_TRUE(
torch_tensorrt::tests::util::almostEqual(jit_results[1], trt_results[1].reshape_as(jit_results[1]), 2e-6));
torch_tensorrt::tests::util::almostEqual(jit_results[1], trt_results[1].reshape_as(jit_results[1]), 8e-5));
}
12 changes: 6 additions & 6 deletions tests/util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ bool cosineSimEqual(const at::Tensor& computed_tensor, const at::Tensor& gt_tens
computed_tensor.flatten(), gt_tensor.flatten(), torch::nn::functional::CosineSimilarityFuncOptions().dim(0));
std::ostringstream ss;
ss << computed_tensor << std::endl << gt_tensor << std::endl;
LOG_GRAPH(ss.str());
LOG_GRAPH(std::string("Cosine Similarity score: ") + std::to_string(cosine_sim.item<float>()));
LOG_GRAPH(std::string("Acceptable Threshold: ") + std::to_string(threshold));
LOG_DEBUG(ss.str());
LOG_DEBUG(std::string("Cosine Similarity score: ") + std::to_string(cosine_sim.item<float>()));
LOG_DEBUG(std::string("Acceptable Threshold: ") + std::to_string(threshold));

return cosine_sim.item<float>() >= threshold;
}
Expand All @@ -31,14 +31,14 @@ bool almostEqual(const at::Tensor& computed_tensor, const at::Tensor& gt_tensor,
auto result = diff.abs().max().item<float>();
auto threshold = atol + (rtol * gt_tensor.abs().max().item<float>());

LOG_GRAPH(std::string("Max Difference: ") + std::to_string(result));
LOG_GRAPH(std::string("Acceptable Threshold: ") + std::to_string(threshold));
LOG_DEBUG(std::string("Max Difference: ") + std::to_string(result));
LOG_DEBUG(std::string("Acceptable Threshold: ") + std::to_string(threshold));

return result <= threshold;
}

bool exactlyEqual(const at::Tensor& computed_tensor, const at::Tensor& gt_tensor) {
LOG_GRAPH(computed_tensor << std::endl << gt_tensor << std::endl);
LOG_DEBUG(computed_tensor << std::endl << gt_tensor << std::endl);
std::cout << "Max Difference: " << (computed_tensor - gt_tensor).abs().max().item<float>() << std::endl;

return (computed_tensor - gt_tensor).abs().max().item<float>() == 0.f;
Expand Down