@@ -137,3 +137,37 @@ TEST(Partitioning, InferBranchModelSegmentedBlockShapeCorrectly) {
137137 {{3 , 32 , 16 , 16 }},
138138 {{3 , 32 , 16 , 16 }, {16 , 32 , 3 , 3 }, {16 }, {3 , 16 , 16 , 16 }}}));
139139}
140+
141+ TEST (Partitioning, PopulateInputIValuesDynamic) {
142+ const auto graph = R"IR(
143+ graph(%0 : Tensor, %1 : Tensor):
144+ %2 : float = prim::Constant[value=1]()
145+ %30 : Tensor = aten::add(%0, %1, %2)
146+ return (%30))IR" ;
147+
148+ auto g = std::make_shared<torch::jit::Graph>();
149+ torch::jit::parseIR (graph, g.get (), true );
150+
151+ torch_tensorrt::core::partitioning::PartitioningInfo partitioning_info;
152+ partitioning_info.enabled = true ;
153+ partitioning_info.truncate_long_and_double = true ;
154+ std::vector<torch_tensorrt::core::ir::Input> inputs;
155+
156+ inputs.push_back (torch_tensorrt::core::ir::Input ({1 }, {2 }, {3 }));
157+ inputs.push_back (torch_tensorrt::core::ir::Input ({1 }));
158+
159+ std::unordered_map<const torch::jit::Value*, std::vector<torch_tensorrt::core::ir::Input>> inputs_map;
160+ std::unordered_map<const torch::jit::Value*, std::vector<c10::optional<at::ScalarType>>> input_types;
161+ inputs_map.insert ({g->inputs ()[0 ], {inputs[0 ]}});
162+ inputs_map.insert ({g->inputs ()[1 ], {inputs[1 ]}});
163+ input_types.insert ({g->inputs ()[0 ], {{at::kFloat }}});
164+ input_types.insert ({g->inputs ()[1 ], {{at::kFloat }}});
165+
166+ partitioning_info.collection_input_spec_map = inputs_map;
167+ torch_tensorrt::core::partitioning::PartitioningCtx ctx (g->block (), partitioning_info);
168+ ctx.input_types_map = input_types;
169+
170+ torch_tensorrt::core::partitioning::populateInputIValues (&ctx);
171+ ASSERT_EQ (ctx.min_input_ivalues_map .size (), 2UL );
172+ ASSERT_EQ (ctx.max_input_ivalues_map .size (), 2UL );
173+ }
0 commit comments