From 748ecf3755c165da343db87f02346fa2f32bf52a Mon Sep 17 00:00:00 2001 From: Naren Dasan Date: Sat, 16 Oct 2021 21:35:27 -0700 Subject: [PATCH] fix(//core/partitioing): Fixing support for paritally compiling graphs with FP16 weights Signed-off-by: Naren Dasan Signed-off-by: Naren Dasan --- core/compiler.cpp | 148 +++++++++--------- core/compiler.h | 3 +- core/conversion/BUILD | 1 - core/conversion/conversion.cpp | 41 ++--- core/conversion/conversion.h | 14 +- core/ir/BUILD | 4 +- core/ir/Input.cpp | 11 +- .../StaticParams.cpp} | 16 +- core/ir/ir.cpp | 50 ++++++ core/ir/ir.h | 24 ++- core/partitioning/SegmentedBlock.h | 19 ++- core/partitioning/partitioning.cpp | 23 ++- core/partitioning/partitioning.h | 4 +- core/partitioning/shape_analysis.cpp | 38 +++-- core/partitioning/shape_analysis.h | 7 +- core/util/BUILD | 5 +- core/util/jit_util.cpp | 111 +++++++++---- core/util/jit_util.h | 12 +- core/util/logging/TRTorchLogger.cpp | 2 +- cpp/BUILD | 1 + cpp/src/compile_spec.cpp | 37 +++-- tests/core/BUILD | 2 +- .../conversion/converters/test_activation.cpp | 40 ++--- .../conversion/converters/test_batch_norm.cpp | 8 +- .../core/conversion/converters/test_cast.cpp | 20 +-- .../core/conversion/converters/test_clone.cpp | 4 +- .../conversion/converters/test_concat.cpp | 16 +- .../converters/test_constant_pad.cpp | 36 ++--- .../converters/test_conv_deconv.cpp | 64 ++++---- .../core/conversion/converters/test_copy.cpp | 4 +- .../conversion/converters/test_cumsum.cpp | 16 +- .../converters/test_element_wise.cpp | 4 +- .../conversion/converters/test_expand.cpp | 64 ++++---- .../converters/test_instance_norm.cpp | 18 +-- .../converters/test_interpolate.cpp | 12 +- .../conversion/converters/test_layer_norm.cpp | 20 +-- .../conversion/converters/test_linear.cpp | 8 +- .../conversion/converters/test_lstm_cell.cpp | 24 +-- .../converters/test_matrix_multiply.cpp | 12 +- .../conversion/converters/test_normalize.cpp | 8 +- .../conversion/converters/test_pooling.cpp | 76 ++++----- .../converters/test_quantization.cpp | 8 +- .../conversion/converters/test_reduce.cpp | 40 ++--- .../converters/test_replication_pad.cpp | 36 ++--- .../conversion/converters/test_select.cpp | 44 +++--- .../conversion/converters/test_shuffle.cpp | 60 +++---- .../conversion/converters/test_softmax.cpp | 20 +-- .../conversion/converters/test_squeeze.cpp | 8 +- .../core/conversion/converters/test_stack.cpp | 8 +- .../core/conversion/converters/test_topk.cpp | 4 +- .../core/conversion/converters/test_unary.cpp | 4 +- .../conversion/converters/test_unsqueeze.cpp | 8 +- .../evaluators/test_aten_evaluators.cpp | 16 +- .../lowering/test_module_fallback_passes.cpp | 6 +- tests/core/lowering/test_unpack_hardswish.cpp | 8 +- tests/core/partitioning/test_conditionals.cpp | 5 +- .../test_fallback_graph_output.cpp | 11 +- tests/core/partitioning/test_segmentation.cpp | 3 +- .../core/partitioning/test_shape_analysis.cpp | 14 +- .../core/partitioning/test_stitched_graph.cpp | 16 +- tests/util/run_graph.cpp | 2 +- tests/util/run_graph_engine.cpp | 28 +++- tests/util/util.h | 8 +- 63 files changed, 791 insertions(+), 593 deletions(-) rename core/{conversion/InterfaceTypes.cpp => ir/StaticParams.cpp} (54%) create mode 100644 core/ir/ir.cpp diff --git a/core/compiler.cpp b/core/compiler.cpp index 35ad0e204f..ccccc512ae 100644 --- a/core/compiler.cpp +++ b/core/compiler.cpp @@ -128,22 +128,6 @@ bool CheckMethodOperatorSupport(const torch::jit::script::Module& mod, std::stri return conversion::VerifyConverterSupportForBlock(g->block()); } -std::string ConvertGraphToTRTEngine(const torch::jit::script::Module& mod, std::string method_name, CompileSpec cfg) { - // Go through Lowering to simplify graph and extract weight parameters - auto graph_and_parameters = lowering::Lower(mod, method_name, cfg.lower_info); - - auto convert_cfg = std::move(cfg.convert_info); - auto g = graph_and_parameters.first; - - auto params = graph_and_parameters.second; - auto named_params = conversion::get_named_params(g->inputs(), params); - - LOG_INFO(*g << "(CompileGraph)\n"); - - auto engine = conversion::ConvertBlockToEngine(g->block(), convert_cfg, named_params); - return std::move(engine); -} - void AddSegmentedBlockToGraph( std::shared_ptr& g, partitioning::SegmentedBlock& seg, @@ -237,15 +221,15 @@ void AddIfBlockToGraph( GraphAndMapping ConstructFallbackGraph( torch::jit::script::Module& new_mod, torch::jit::Block* block, - std::unordered_map input_ivalues_map, + std::unordered_map example_tensor_map, CompileSpec cfg, - conversion::GraphParams named_params) { + ir::StaticParams static_params) { auto convert_cfg = cfg.convert_info; auto partition_info = cfg.partition_info; auto new_g = std::make_shared(); - auto segmented_blocks = partitioning::Partition(block, input_ivalues_map, partition_info); + auto segmented_blocks = partitioning::Partition(block, example_tensor_map, partition_info); // the mapping from lowering graph => fallback global graph std::unordered_map old_to_new_g; @@ -259,13 +243,17 @@ GraphAndMapping ConstructFallbackGraph( trt_engine_id << reinterpret_cast(&seg_block); if (seg_block.target() == partitioning::SegmentedBlock::kTensorRT) { + auto shapes = seg_block.in_shapes(); + auto types = seg_block.in_types(); std::vector inputs; - for (auto& shape : seg_block.in_shape()) { - inputs.push_back(ir::Input(shape)); + for (size_t i = 0; i < shapes.size(); i++) { + auto in = ir::Input(shapes[i]); + in.dtype = util::ScalarTypeToTRTDataType(types[i]); + inputs.push_back(in); } // update the input ranges for each segments - convert_cfg.inputs = inputs; - auto engine = conversion::ConvertBlockToEngine(seg_block.block(), convert_cfg, named_params); + convert_cfg.inputs = ir::associate_specs_with_inputs(seg_block.g(), inputs, static_params); + auto engine = conversion::ConvertBlockToEngine(seg_block.block(), convert_cfg, static_params); auto temp_g = std::make_shared(); auto device_spec = convert_cfg.engine_settings.device; auto cuda_device = runtime::CudaDevice(device_spec.gpu_id, device_spec.device_type); @@ -281,7 +269,7 @@ GraphAndMapping ConstructFallbackGraph( std::vector graph_and_mappings; for (auto cur_block : if_node->blocks()) { graph_and_mappings.push_back( - ConstructFallbackGraph(new_mod, cur_block, input_ivalues_map, cfg, named_params)); + ConstructFallbackGraph(new_mod, cur_block, example_tensor_map, cfg, static_params)); } AddIfBlockToGraph(new_g, if_node, graph_and_mappings, old_to_new_g); @@ -299,54 +287,28 @@ GraphAndMapping ConstructFallbackGraph( return {new_g, old_to_new_g}; } -torch::jit::script::Module CompileGraphWithFallback(const torch::jit::script::Module& mod, CompileSpec cfg) { - // TODO: Should be doing a functional transform but need PR #31978 - // [jit] More robust mangling - // torch::jit::script::Module new_mod = mod.clone(); - torch::jit::script::Module new_mod(mod._ivalue()->name() + "_trt"); - std::vector> graphs; - for (const torch::jit::script::Method& method : mod.get_methods()) { - // Compile only forward methods. forward method contains the entire graph. - if (method.name().compare("forward") == 0) { - auto new_g = std::make_shared(); - auto graph_and_parameters = lowering::Lower(mod, method.name(), cfg.lower_info); +std::string ConvertGraphToTRTEngine(const torch::jit::script::Module& mod, std::string method_name, CompileSpec cfg) { + // Go through Lowering to simplify graph and extract weight parameters + auto graph_and_parameters = lowering::Lower(mod, method_name, cfg.lower_info); - auto g = graph_and_parameters.first; - auto params = graph_and_parameters.second; - auto named_params = conversion::get_named_params(g->inputs(), params); - LOG_INFO("(LoweredGraph)\n" << *g); + auto convert_cfg = std::move(cfg.convert_info); + auto g = graph_and_parameters.first; - std::unordered_map inputs; - for (size_t i = 0; i < g->inputs().size(); ++i) { - inputs.insert({g->inputs()[i], cfg.convert_info.inputs[i]}); - } - auto input_ivalues_map = partitioning::generateRandomInputs(inputs); - auto graph_and_mapping = ConstructFallbackGraph(new_mod, g->block(), input_ivalues_map, cfg, named_params); - new_g = graph_and_mapping.first; - LOG_INFO("(FallbackGraph)\n" << *new_g); + auto params = graph_and_parameters.second; + auto static_params = ir::get_static_params(g->inputs(), params); - // if there is no tensorrt engine self in fallback graph, there is no conversion, we just return the initial - // module - if (new_g->inputs()[0]->type()->str().find("__torch__") == std::string::npos) { - LOG_WARNING("Didn't generate any TensorRT engines, the compiler did nothing\n"); - return mod; - } + LOG_INFO(*g << "(CompileGraph)\n"); - auto new_method = new_mod._ivalue()->compilation_unit()->create_function(method.name(), new_g); - auto schema = util::GenerateGraphSchema(new_method->name(), new_g); - new_mod.type()->addMethod(new_method); - new_method->setSchema(schema); - } - } + // Move the user defined inputs to the convert_cfg since some might be static; + convert_cfg.inputs = std::move(ir::associate_specs_with_inputs(g, cfg.inputs, static_params)); - return new_mod; + auto engine = conversion::ConvertBlockToEngine(g->block(), convert_cfg, static_params); + return std::move(engine); } -torch::jit::script::Module CompileGraph(const torch::jit::script::Module& mod, CompileSpec cfg) { - // TODO: not sure how to deal with duplicated code here, so just cut out a branch temporally - if (cfg.partition_info.enabled) { - return CompileGraphWithFallback(mod, cfg); - } +torch::jit::Module CompileGraph(const torch::jit::Module& mod, CompileSpec cfg) { + torch::jit::Module new_mod(mod._ivalue()->name() + "_trt"); + auto device_spec = cfg.convert_info.engine_settings.device; // GPU default WS size : 1 GB @@ -362,25 +324,59 @@ torch::jit::script::Module CompileGraph(const torch::jit::script::Module& mod, C } } - // TODO: Should be doing a functional transform but need PR #31978 - // [jit] More robust mangling - // torch::jit::script::Module new_mod = mod.clone(); - torch::jit::script::Module new_mod(mod._ivalue()->name() + "_trt"); - std::vector> graphs; - for (const torch::jit::script::Method& method : mod.get_methods()) { - // Compile only forward methods. forward method contains the entire graph. + for (const torch::jit::Method& method : mod.get_methods()) { if (method.name().compare("forward") == 0) { - auto engine = ConvertGraphToTRTEngine(mod, method.name(), cfg); auto new_g = std::make_shared(); - auto cuda_device = runtime::CudaDevice(device_spec.gpu_id, device_spec.device_type); - AddEngineToGraph(new_mod, new_g, engine, cuda_device); + + auto graph_and_parameters = lowering::Lower(mod, method.name(), cfg.lower_info); + + auto g = graph_and_parameters.first; + LOG_INFO("Lowered Graph: " << *g); + auto params = graph_and_parameters.second; + auto static_params = ir::get_static_params(g->inputs(), params); + + cfg.convert_info.inputs = std::move(ir::associate_specs_with_inputs(g, cfg.inputs, static_params)); + + // If the user did not explicitly set the input type, then use the first + // tensor calculation to infer type. + auto first_use_types = util::get_block_first_calc_dtypes_opt(g->block()); + for (auto& in : g->inputs()) { + auto est_type_opt = first_use_types[in]; + ir::Input& spec = cfg.convert_info.inputs.find(in)->second; + if (est_type_opt && !spec.dtype_is_user_defined) { + spec.dtype = util::ScalarTypeToTRTDataType(est_type_opt.value()); + } else if (!est_type_opt && !spec.dtype_is_user_defined) { + LOG_WARNING( + "Cannot deterime input type from calcuations in graph for input " + << in->debugName() << ". Assuming it is Float32. If not, specify input type explicity"); + spec.dtype = nvinfer1::DataType::kFLOAT; + } + } + + if (cfg.partition_info.enabled) { + auto input_ivalues_map = partitioning::generateRandomInputs(cfg.convert_info.inputs, first_use_types); + auto graph_and_mapping = ConstructFallbackGraph(new_mod, g->block(), input_ivalues_map, cfg, static_params); + new_g = graph_and_mapping.first; + LOG_INFO("Segmented Graph: " << *new_g); + + // if there is no tensorrt engine self in fallback graph, there is no conversion, we just return the initial + // module + if (new_g->inputs()[0]->type()->str().find("__torch__") == std::string::npos) { + LOG_WARNING("Didn't generate any TensorRT engines, the compiler did nothing\n"); + return mod; + } + } else { + auto engine = conversion::ConvertBlockToEngine(g->block(), cfg.convert_info, static_params); + auto device_spec = cfg.convert_info.engine_settings.device; + auto cuda_device = runtime::CudaDevice(device_spec.gpu_id, device_spec.device_type); + AddEngineToGraph(new_mod, new_g, engine, cuda_device); + } auto new_method = new_mod._ivalue()->compilation_unit()->create_function(method.name(), new_g); auto schema = util::GenerateGraphSchema(new_method->name(), new_g); new_mod.type()->addMethod(new_method); new_method->setSchema(schema); } } - return new_mod; } diff --git a/core/compiler.h b/core/compiler.h index cec0b45f17..fda6fc5b25 100644 --- a/core/compiler.h +++ b/core/compiler.h @@ -13,7 +13,8 @@ namespace trtorch { namespace core { struct CompileSpec { - CompileSpec(std::vector inputs) : convert_info(std::move(inputs)) {} + CompileSpec(std::vector inputs) : inputs(inputs) {} + std::vector inputs; conversion::ConversionInfo convert_info; lowering::LowerInfo lower_info; partitioning::PartitionInfo partition_info; diff --git a/core/conversion/BUILD b/core/conversion/BUILD index 13d5b32eb2..99fde4d2a2 100644 --- a/core/conversion/BUILD +++ b/core/conversion/BUILD @@ -10,7 +10,6 @@ config_setting( cc_library( name = "conversion", srcs = [ - "InterfaceTypes.cpp", "conversion.cpp", "conversion_ignorelist.cpp", ], diff --git a/core/conversion/conversion.cpp b/core/conversion/conversion.cpp index 27dc286637..248fad1e41 100644 --- a/core/conversion/conversion.cpp +++ b/core/conversion/conversion.cpp @@ -128,7 +128,10 @@ void AddLayer(ConversionCtx* ctx, const torch::jit::Node* n) { << "please report this error to https://www.github.com/NVIDIA/TRTorch/issues"); } -void AddInputs(ConversionCtx* ctx, at::ArrayRef inputs, std::vector& input_specs) { +void AddInputs( + ConversionCtx* ctx, + c10::ArrayRef inputs, + std::unordered_map& input_specs) { std::vector input_tensors; for (auto in : inputs) { // Disregarding inputs that are not tensors @@ -143,24 +146,23 @@ void AddInputs(ConversionCtx* ctx, at::ArrayRef inputs } std::stringstream ss; - ss << "Input Dimension Specs: [\n"; + ss << "Input Dimension Specs: {" << std::endl; for (auto i : input_specs) { - ss << " " << i << ","; + ss << " " << i.first->debugName() << " : " << i.second << ","; } - ss << ']'; - LOG_DEBUG(ctx->logger, ss.str()); - - TRTORCH_CHECK( - input_tensors.size() == input_specs.size(), - "Expected dimension specifications for all input tensors" - << ", but found " << input_tensors.size() << " input tensors and " << input_specs.size() - << " dimension specs (conversion.AddInputs)"); + ss << '}'; + auto dbg_str = ss.str(); + LOG_DEBUG(ctx->logger, dbg_str); auto profile = ctx->builder->createOptimizationProfile(); - for (size_t i = 0; i < input_tensors.size(); i++) { - auto in = input_tensors[i]; - auto spec = input_specs[i]; + for (auto input : input_tensors) { + const torch::jit::Value* in = input; + TRTORCH_CHECK( + input_specs.find(in) != input_specs.end(), + "Cannot find an input spec associated with input: " << in->debugName()); + ir::Input& spec = input_specs.find(in)->second; + std::string name = std::string("input_") + std::to_string(ctx->num_inputs); LOG_INFO( ctx->logger, @@ -226,7 +228,7 @@ void MarkOutputs(ConversionCtx* ctx, at::ArrayRef outp } } -void AddParamsToCtxValueMap(ConversionCtx* ctx, GraphParams& params) { +void AddParamsToCtxValueMap(ConversionCtx* ctx, ir::StaticParams& params) { for (auto p : params) { ctx->evaluated_value_map[p.first] = std::move(p.second); } @@ -358,8 +360,8 @@ void EvaluateLoopBlock(ConversionCtx* ctx, const torch::jit::Node* n) { void ConvertBlockToNetDef( ConversionCtx* ctx, const torch::jit::Block* b, - ConversionInfo build_info, - GraphParams& static_params) { + ConversionInfo& build_info, + ir::StaticParams& static_params) { LOG_INFO(ctx->logger, "Converting Block"); auto inputs = b->inputs(); @@ -435,7 +437,10 @@ void ConvertBlockToNetDef( // a serialized TensorRT engine that can be deserialized and run // Probably should consolidate these two functions -std::string ConvertBlockToEngine(const torch::jit::Block* b, ConversionInfo build_info, GraphParams& static_params) { +std::string ConvertBlockToEngine( + const torch::jit::Block* b, + ConversionInfo build_info, + ir::StaticParams& static_params) { ConversionCtx ctx(build_info.engine_settings); ConvertBlockToNetDef(&ctx, b, build_info, static_params); std::string engine = ctx.SerializeEngine(); diff --git a/core/conversion/conversion.h b/core/conversion/conversion.h index 253dce7e60..2d60351edc 100644 --- a/core/conversion/conversion.h +++ b/core/conversion/conversion.h @@ -12,20 +12,16 @@ namespace core { namespace conversion { struct ConversionInfo { - std::vector inputs; + ir::InputSpecMap inputs; BuilderSettings engine_settings; - ConversionInfo(std::vector inputs) : inputs(std::move(inputs)), engine_settings(BuilderSettings()) {} }; -// TODO: REMOVE GRAPH AND PARAMS AND MOVE FULLY TO INLINED CONSTANTS - -using GraphParams = std::map; - -GraphParams get_named_params(c10::ArrayRef inputs, std::vector params); - // Converts a already lowered block (blocks with no sub blocks) to // a serialized TensorRT engine that can be deserialized and run -std::string ConvertBlockToEngine(const torch::jit::Block* b, ConversionInfo build_info, GraphParams& static_params); +std::string ConvertBlockToEngine( + const torch::jit::Block* b, + ConversionInfo build_info, + ir::StaticParams& static_params); bool OpSupported(const torch::jit::Node* n); diff --git a/core/ir/BUILD b/core/ir/BUILD index 374b8e91c7..a613aaf489 100644 --- a/core/ir/BUILD +++ b/core/ir/BUILD @@ -13,7 +13,9 @@ cc_library( "ir.h" ], srcs = [ - "Input.cpp" + "ir.cpp", + "Input.cpp", + "StaticParams.cpp" ], deps = [ "@tensorrt//:nvinfer", diff --git a/core/ir/Input.cpp b/core/ir/Input.cpp index 900882675b..db2b633908 100644 --- a/core/ir/Input.cpp +++ b/core/ir/Input.cpp @@ -62,7 +62,11 @@ bool valid_input_dtype(nvinfer1::DataType dtype) { } } -Input::Input(std::vector shape, nvinfer1::DataType dtype, nvinfer1::TensorFormat format) { +Input::Input( + std::vector shape, + nvinfer1::DataType dtype, + nvinfer1::TensorFormat format, + bool dtype_is_user_defined) { if (shape.size() > 5) { LOG_WARNING("Verify that this dim size is accepted"); } @@ -81,6 +85,7 @@ Input::Input(std::vector shape, nvinfer1::DataType dtype, nvinfer1::Ten << dtype << ", " << format << "), TRTorch only supports contiguous format (NCHW) except with input type Float32 where channel last (NHWC) is also supported"); this->format = format; + this->dtype_is_user_defined = dtype_is_user_defined; } Input::Input( @@ -88,7 +93,8 @@ Input::Input( std::vector opt_shape, std::vector max_shape, nvinfer1::DataType dtype, - nvinfer1::TensorFormat format) { + nvinfer1::TensorFormat format, + bool dtype_is_user_defined) { if (min_shape.size() > 5 || opt_shape.size() > 5 || max_shape.size() > 5) { LOG_WARNING("Verify that this dim size is accepted"); } @@ -132,6 +138,7 @@ Input::Input( << dtype << ", " << format << "), TRTorch only supports contiguous format (NCHW) except with input type Float32 where channel last (NHWC) is also supported"); this->format = format; + this->dtype_is_user_defined = dtype_is_user_defined; } std::ostream& operator<<(std::ostream& os, const Input& input) { diff --git a/core/conversion/InterfaceTypes.cpp b/core/ir/StaticParams.cpp similarity index 54% rename from core/conversion/InterfaceTypes.cpp rename to core/ir/StaticParams.cpp index f7d6565f26..7a6448382a 100644 --- a/core/conversion/InterfaceTypes.cpp +++ b/core/ir/StaticParams.cpp @@ -1,28 +1,28 @@ #include -#include "core/conversion/conversion.h" +#include "core/ir/ir.h" #include "core/util/prelude.h" namespace trtorch { namespace core { -namespace conversion { +namespace ir { -GraphParams get_named_params(c10::ArrayRef inputs, std::vector params) { - GraphParams named_params; +StaticParams get_static_params(c10::ArrayRef inputs, std::vector params) { + StaticParams static_params; auto param_it = params.begin(); for (auto in : inputs) { if (in->type() != c10::TensorType::get() && param_it != params.end()) { - named_params[in] = *param_it; + static_params[in] = *param_it; ++param_it; } } TRTORCH_CHECK( - named_params.size() == params.size(), + static_params.size() == params.size(), "Graph parameter parsing failed, mismatched number of static parameters and IValues") - return std::move(named_params); + return std::move(static_params); } -} // namespace conversion +} // namespace ir } // namespace core } // namespace trtorch diff --git a/core/ir/ir.cpp b/core/ir/ir.cpp new file mode 100644 index 0000000000..969b3b38c4 --- /dev/null +++ b/core/ir/ir.cpp @@ -0,0 +1,50 @@ +#include "core/ir/ir.h" +#include "core/util/prelude.h" + +namespace trtorch { +namespace core { +namespace ir { + +InputSpecMap associate_specs_with_inputs( + std::shared_ptr& g, + std::vector specs, + StaticParams& static_params) { + auto tensor_inputs = get_tensor_inputs(g, static_params); + return pair_input_vals_with_specs(tensor_inputs, specs); +} + +InputSpecMap pair_input_vals_with_specs(std::vector vals, std::vector specs) { + TRTORCH_CHECK( + vals.size() == specs.size(), + "Expected dimension specifications for all input tensors" + << ", but found " << vals.size() << " input tensors and " << specs.size() << " dimension specs"); + + std::unordered_map a; + for (size_t i = 0; i < vals.size(); i++) { + LOG_DEBUG("Paring " << i << ": " << vals[i]->debugName() << " : " << specs[i]); + a.insert({vals[i], specs[i]}); + } + return std::move(a); +} + +std::vector get_tensor_inputs( + std::shared_ptr& g, + StaticParams& static_params) { + std::vector input_tensors; + auto inputs = g->inputs(); + for (auto in : inputs) { + // Disregarding inputs that are not tensors or are static + // + // Ex. + // self.1:__torch__.alexnet -> ignored + // input.1:Tensor -> used + if (in->type()->isSubtypeOf(c10::TensorType::get()) && static_params.find(in) == static_params.end()) { + input_tensors.push_back(in); + } + } + return input_tensors; +} + +} // namespace ir +} // namespace core +} // namespace trtorch \ No newline at end of file diff --git a/core/ir/ir.h b/core/ir/ir.h index 3d1449185e..7499ef794b 100644 --- a/core/ir/ir.h +++ b/core/ir/ir.h @@ -1,8 +1,11 @@ #pragma once #include +#include #include + #include "NvInfer.h" +#include "torch/csrc/jit/ir/ir.h" namespace trtorch { namespace core { @@ -14,16 +17,19 @@ struct Input { Input( std::vector shape, nvinfer1::DataType dtype = nvinfer1::DataType::kFLOAT, - nvinfer1::TensorFormat format = nvinfer1::TensorFormat::kLINEAR); + nvinfer1::TensorFormat format = nvinfer1::TensorFormat::kLINEAR, + bool dtype_is_user_defined = false); Input( std::vector min_shape, std::vector opt_shape, std::vector max_shape, nvinfer1::DataType dtype = nvinfer1::DataType::kFLOAT, - nvinfer1::TensorFormat format = nvinfer1::TensorFormat::kLINEAR); + nvinfer1::TensorFormat format = nvinfer1::TensorFormat::kLINEAR, + bool dtype_is_used_defined = false); friend std::ostream& operator<<(std::ostream& os, const Input& input); bool input_is_dynamic = false; + bool dtype_is_user_defined = false; nvinfer1::Dims input_shape; nvinfer1::Dims min; nvinfer1::Dims max; @@ -32,6 +38,20 @@ struct Input { nvinfer1::TensorFormat format; }; +using StaticParams = std::map; +StaticParams get_static_params(c10::ArrayRef inputs, std::vector params); + +using InputSpecMap = std::unordered_map; + +InputSpecMap associate_specs_with_inputs( + std::shared_ptr& g, + std::vector specs, + StaticParams& static_params); +InputSpecMap pair_input_vals_with_specs(std::vector vals, std::vector specs); +std::vector get_tensor_inputs( + std::shared_ptr& g, + StaticParams& static_params); + } // namespace ir } // namespace core } // namespace trtorch diff --git a/core/partitioning/SegmentedBlock.h b/core/partitioning/SegmentedBlock.h index fd6f648faf..0c51d7062f 100644 --- a/core/partitioning/SegmentedBlock.h +++ b/core/partitioning/SegmentedBlock.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include "NvInfer.h" #include "core/ir/ir.h" @@ -73,11 +73,17 @@ struct SegmentedBlock { bool contain_raw_value(torch::jit::Value* input) { return old_to_new_.count(input); } - void register_inshape(std::vector& in_shape) { - in_shape_ = in_shape; + void register_inshapes(std::vector& in_shapes) { + in_shapes_ = in_shapes; + } + const std::vector& in_shapes() const { + return in_shapes_; + } + void register_intypes(std::vector& in_types) { + in_types_ = in_types; } - const std::vector& in_shape() const { - return in_shape_; + const std::vector& in_types() const { + return in_types_; } void update_target(SegmentedBlockTarget new_target) { target_ = new_target; @@ -91,7 +97,8 @@ struct SegmentedBlock { private: BlockID id_; SegmentedBlockTarget target_; - std::vector in_shape_; + std::vector in_shapes_; + std::vector in_types_; std::vector inputs_; std::vector outputs_; std::vector nodes_; diff --git a/core/partitioning/partitioning.cpp b/core/partitioning/partitioning.cpp index 9c12420800..86311cccaf 100644 --- a/core/partitioning/partitioning.cpp +++ b/core/partitioning/partitioning.cpp @@ -299,8 +299,11 @@ bool should_run_in_trt(torch::jit::Node* n, const std::unordered_set& nodes) { - SegmentedBlock::BlockID b_id= g.size(); +void finalize_block( + PartitionedGraph& g, + SegmentedBlock::SegmentedBlockTarget kind, + std::vector& nodes) { + SegmentedBlock::BlockID b_id = g.size(); LOG_DEBUG("Finalizing in progress " << SegmentedBlock::target_to_str(kind) << " block"); g.emplace_back(b_id, kind, nodes); nodes.clear(); @@ -337,14 +340,17 @@ PartitionedGraph segment_graph(torch::jit::Block* block, const PartitionInfo& pa if (in_prog_trt_blk_nodes.size() >= min_block_size) { finalize_block(segmented_blocks, SegmentedBlock::kTensorRT, in_prog_trt_blk_nodes); } else { - LOG_DEBUG("In progress TRT block does not meet minimum block size requirements, therefore folding into in progress PyTorch block"); - in_prog_pyt_blk_nodes.insert(in_prog_pyt_blk_nodes.end(), in_prog_trt_blk_nodes.begin(), in_prog_trt_blk_nodes.end()); + LOG_DEBUG( + "In progress TRT block does not meet minimum block size requirements, therefore folding into in progress PyTorch block"); + in_prog_pyt_blk_nodes.insert( + in_prog_pyt_blk_nodes.end(), in_prog_trt_blk_nodes.begin(), in_prog_trt_blk_nodes.end()); } in_prog_trt_blk_nodes.clear(); // if there is a prim::If then this if node will be encapsulated in a SegmentedBlock // we shouldn't inject node for this block in dependency analysis process if (n->kind() == torch::jit::prim::If) { - LOG_DEBUG("Hit a conditional statement, finializing in progress PYT block and creating a new one for the conditional"); + LOG_DEBUG( + "Hit a conditional statement, finializing in progress PYT block and creating a new one for the conditional"); if (!in_prog_pyt_blk_nodes.empty()) { finalize_block(segmented_blocks, SegmentedBlock::kTorch, in_prog_pyt_blk_nodes); } @@ -374,7 +380,8 @@ PartitionedGraph segment_graph(torch::jit::Block* block, const PartitionInfo& pa } if (!in_prog_pyt_blk_nodes.empty()) { - in_prog_pyt_blk_nodes.insert(in_prog_pyt_blk_nodes.end(), in_prog_trt_blk_nodes.begin(), in_prog_trt_blk_nodes.end()); + in_prog_pyt_blk_nodes.insert( + in_prog_pyt_blk_nodes.end(), in_prog_trt_blk_nodes.begin(), in_prog_trt_blk_nodes.end()); finalize_block(segmented_blocks, SegmentedBlock::kTorch, in_prog_pyt_blk_nodes); } @@ -383,7 +390,7 @@ PartitionedGraph segment_graph(torch::jit::Block* block, const PartitionInfo& pa PartitionedGraph Partition( torch::jit::Block* block, - std::unordered_map& input_ivalues_map, + std::unordered_map& example_tensor_map, const PartitionInfo& partition_info) { LOG_DEBUG(partition_info); // segment lowering global graph into blocks @@ -397,7 +404,7 @@ PartitionedGraph Partition( registerSegmentsOutputs(segmented_blocks, block); // run shape analysis on each segmented block - runShapeAnalysis(segmented_blocks, input_ivalues_map, at::kFloat); + runShapeAnalysis(segmented_blocks, example_tensor_map); LOG_INFO(segmented_blocks); diff --git a/core/partitioning/partitioning.h b/core/partitioning/partitioning.h index 0ebbd84816..5d52ac055d 100644 --- a/core/partitioning/partitioning.h +++ b/core/partitioning/partitioning.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include "core/ir/ir.h" #include "core/partitioning/PartitionInfo.h" @@ -20,7 +20,7 @@ PartitionedGraph segment_graph(torch::jit::Block* block, const PartitionInfo& pa PartitionedGraph Partition( torch::jit::Block* block, - std::unordered_map& input_ivalues_map, + std::unordered_map& example_tensor_map, const PartitionInfo& partition_info); std::ostream& operator<<(std::ostream& os, const PartitionedGraph& g); diff --git a/core/partitioning/shape_analysis.cpp b/core/partitioning/shape_analysis.cpp index 39a4702f66..25d0c8d72c 100644 --- a/core/partitioning/shape_analysis.cpp +++ b/core/partitioning/shape_analysis.cpp @@ -7,25 +7,34 @@ namespace trtorch { namespace core { namespace partitioning { -std::unordered_map generateRandomInputs( - std::unordered_map& inputs) { +std::unordered_map generateRandomInputs( + std::unordered_map& inputs, + std::unordered_map>& types) { // generate random inputs for running pytorch segments - std::unordered_map ivalue_maps; - std::vector random_inputs; + std::unordered_map ivalue_map; + uint64_t in_i = 0; for (auto& input : inputs) { auto cur_shape = input.second.input_shape; std::vector shape; shape.insert(shape.begin(), std::begin(cur_shape.d), std::begin(cur_shape.d) + cur_shape.nbDims); - auto in = at::randint(5, shape, {at::kCUDA}); - ivalue_maps[input.first] = in.clone(); + auto type_opt = types[input.first]; + auto type = at::kFloat; + if (type_opt) { + type = type_opt.value(); + } else { + LOG_WARNING("Input type for doing shape analysis could not be determined, defaulting to F32"); + } + auto in = at::randint(5, shape, {at::kCUDA}).to(type); + ivalue_map[input.first] = in.clone(); + in_i++; } - return ivalue_maps; + return ivalue_map; } void getSegmentsOutputByRunning( SegmentedBlock& seg_block, - std::unordered_map& ivalues_maps) { + std::unordered_map& ivalues_maps) { // create a module to run the graph auto g = seg_block.g(); auto copy_g = g->copy(); @@ -95,23 +104,26 @@ void getSegmentsOutputByRunning( } // set input shape for each segmented block so we wil use it in conversion process - std::vector input_shape; + std::vector input_shapes; + std::vector input_types; for (auto& i : seg_block.raw_inputs()) { if (ivalues_maps[i].isTensor()) { - input_shape.push_back(util::toVec(util::toDims(ivalues_maps[i].toTensor().sizes()))); + input_shapes.push_back(util::toVec(util::toDims(ivalues_maps[i].toTensor().sizes()))); + input_types.push_back(ivalues_maps[i].toTensor().scalar_type()); } } - seg_block.register_inshape(input_shape); + seg_block.register_inshapes(input_shapes); + seg_block.register_intypes(input_types); } void runShapeAnalysis( std::vector& segmented_blocks, - std::unordered_map& ivalues_maps) { + std::unordered_map& example_tensor_map) { // register every segment's input shape, and it's running output IValues for (auto& seg_block : segmented_blocks) { torch::jit::ConstantPooling(seg_block.g()); - getSegmentsOutputByRunning(seg_block, ivalues_maps); + getSegmentsOutputByRunning(seg_block, example_tensor_map); } return; } diff --git a/core/partitioning/shape_analysis.h b/core/partitioning/shape_analysis.h index ef3f82dc90..e2659e62a4 100644 --- a/core/partitioning/shape_analysis.h +++ b/core/partitioning/shape_analysis.h @@ -6,12 +6,13 @@ namespace trtorch { namespace core { namespace partitioning { -std::unordered_map generateRandomInputs( - std::unordered_map& input_ranges); +std::unordered_map generateRandomInputs( + std::unordered_map& input_ranges, + std::unordered_map>& input_types); void runShapeAnalysis( std::vector& segmented_blocks, - std::unordered_map& ivalues_maps); + std::unordered_map& ivalues_maps); } // namespace partitioning } // namespace core diff --git a/core/util/BUILD b/core/util/BUILD index 51868ae48d..5934bf3434 100644 --- a/core/util/BUILD +++ b/core/util/BUILD @@ -30,7 +30,9 @@ cc_library( srcs = [ "jit_util.cpp" ], - deps = select({ + deps = [ + ":macros" + ] + select({ ":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"], "//conditions:default": ["@libtorch//:libtorch"], }), @@ -43,6 +45,7 @@ cc_library( ], deps = [ ":exception", + "//core/util/logging", ], ) diff --git a/core/util/jit_util.cpp b/core/util/jit_util.cpp index 9a71bff08a..128546e5f8 100644 --- a/core/util/jit_util.cpp +++ b/core/util/jit_util.cpp @@ -1,22 +1,26 @@ #include "core/util/jit_util.h" +#include "core/util/macros.h" namespace trtorch { namespace core { namespace util { -c10::optional getBlockFirstCalcDType(const std::shared_ptr& b) { - auto ns = b->nodes(); - +c10::optional get_value_first_calc_dtype_opt(torch::jit::Block* b, torch::jit::Value* in) { + TRTORCH_ASSERT(in->owningGraph() == b->owningGraph(), "Provided input is not part of the provided graph"); c10::optional dtype = {}; - // For each node check the inputs to find a prim:Constant, which will provide a static tensor. - // Use that tensor to determine operating dtype for the first calculation in the block - for (auto n : ns) { - if (n->kind() == torch::jit::prim::Constant) { - // Not really helpful to evaluate typing for constants - continue; - } + auto b_ins = b->inputs(); + std::unordered_set b_in_set(b_ins.begin(), b_ins.end()); + + TRTORCH_ASSERT( + in->type() == c10::TensorType::get(), "Input is not a tensor, cannot check for dtype based on calculation"); + auto consumers = in->uses(); + auto search_list = std::vector(consumers.begin(), consumers.end()); + + for (auto& u : search_list) { + auto n = u.user; + LOG_GRAPH("Node we are looking at: " << util::node_info(n)); auto ins = n->inputs(); auto outs = n->outputs(); @@ -24,46 +28,87 @@ c10::optional getBlockFirstCalcDType(const std::shared_ptrtype() == c10::TensorType::get()) { outputs_tensor = true; + break; } } - if (outputs_tensor) { - // If all input tensors are block inputs then this node will not give us useful type info so move to the next one - std::unordered_set node_input_set = {ins.begin(), ins.end()}; + if (!outputs_tensor) { + LOG_GRAPH("Node " << util::node_info(n) << " does not output a tensor, skipping"); + continue; + } - bool all_n_ins_are_b_ins = true; - for (auto b_in : b->inputs()) { - if (node_input_set.find(b_in) == node_input_set.end()) { - all_n_ins_are_b_ins = false; - } - } + LOG_GRAPH("Node " << util::node_info(n) << " outputs a tensor"); - if (all_n_ins_are_b_ins) { - continue; + // If all input tensors are block inputs then this node will not give us useful type info so move to the next one + bool all_n_ins_are_b_ins = true; + for (auto in : ins) { + if (b_in_set.find(in) == b_in_set.end()) { + all_n_ins_are_b_ins = false; + break; } + } + if (all_n_ins_are_b_ins) { + LOG_GRAPH( + "All inputs to Node " << util::node_info(n) << " are graph inputs, cannot be used to determine input type"); + for (auto o : outs) { + if (o->type() == c10::TensorType::get()) { + auto o_uses = o->uses(); + search_list.insert(search_list.end(), o_uses.begin(), o_uses.end()); + } + } + continue; + } - // If node outputs a Tensor it might be a result of tensor calcuation so check to see - // if any inputs to the calculation can give us hints - c10::optional const_tensor_n = {}; + // If node outputs a Tensor it might be a result of tensor calcuation so check to see + // if any inputs to the calculation can give us hints + c10::optional const_tensor_n = {}; - // Backtrace to constants which will immediately give us the Tensor type if possible - for (auto in : ins) { - if (in->type() == c10::TensorType::get()) { - if (in->node()->kind() == torch::jit::prim::Constant) { - auto const_ival = in->node()->get(c10::Symbol::attr("value")); - dtype = {const_ival.value().toTensor().scalar_type()}; - goto exit_first_calc_dtype; - } + // Backtrace to constants which will immediately give us the Tensor type if possible + for (auto in : ins) { + LOG_GRAPH("Input to node: " << util::node_info(in->node())); + if (in->type()->isSubtypeOf(torch::jit::TensorType::get())) { + LOG_GRAPH("Input outputs a Tensor"); + if (in->node()->kind() == torch::jit::prim::Constant) { + LOG_GRAPH("Input is a constant"); + auto const_val = in->node()->t(c10::attr::value); + LOG_GRAPH("Found that constant tensor has type: " << const_val.scalar_type()); + dtype = {const_val.scalar_type()}; + goto exit_first_calc_dtype; } } } - } + // Add all tensor outputs to search list if we still dont know + for (auto o : outs) { + if (o->type() == c10::TensorType::get()) { + auto o_uses = o->uses(); + search_list.insert(search_list.end(), o_uses.begin(), o_uses.end()); + } + } + } exit_first_calc_dtype: + if (dtype) { + LOG_GRAPH("Estimated input type is " << dtype.value()); + } else { + LOG_GRAPH("Cannot determine input types from graph"); + } return dtype; } +std::unordered_map> get_block_first_calc_dtypes_opt( + torch::jit::Block* b) { + std::unordered_map> types; + + for (auto i : b->inputs()) { + if (i->type() == c10::TensorType::get()) { + torch::jit::Value* in = i; + types.insert({in, get_value_first_calc_dtype_opt(b, i)}); + } + } + return types; +} + } // namespace util } // namespace core } // namespace trtorch diff --git a/core/util/jit_util.h b/core/util/jit_util.h index 530b49ccda..7fa0739873 100644 --- a/core/util/jit_util.h +++ b/core/util/jit_util.h @@ -17,6 +17,14 @@ inline std::string node_info(const torch::jit::Node* n) { return node_info; } +inline std::string value_info(const torch::jit::Value* v) { + std::stringstream ss; + ss << node_info(v->node()); + std::string value_info = ss.str(); + value_info.erase(std::remove(value_info.begin(), value_info.end(), '\n'), value_info.end()); + return value_info; +} + inline std::string schema_info(const torch::jit::FunctionSchema* s) { std::stringstream ss; ss << *s; @@ -52,7 +60,9 @@ inline std::string GetPyTorchSourceCode(const torch::jit::Node* n) { return source_code; } -c10::optional getBlockFirstCalcDType(const std::shared_ptr& b); +c10::optional get_value_first_calc_dtype_opt(torch::jit::Block* b, torch::jit::Value* in); +std::unordered_map> get_block_first_calc_dtypes_opt( + torch::jit::Block* b); } // namespace util } // namespace core diff --git a/core/util/logging/TRTorchLogger.cpp b/core/util/logging/TRTorchLogger.cpp index 0f7030193a..1be2cfa3ce 100644 --- a/core/util/logging/TRTorchLogger.cpp +++ b/core/util/logging/TRTorchLogger.cpp @@ -125,7 +125,7 @@ namespace { TRTorchLogger& get_global_logger() { #ifndef NDEBUG - static TRTorchLogger global_logger("[TRTorch - Debug Build] - ", LogLevel::kGRAPH, true); + static TRTorchLogger global_logger("[TRTorch - Debug Build] - ", LogLevel::kDEBUG, true); #else static TRTorchLogger global_logger("[TRTorch] - ", LogLevel::kERROR, false); #endif diff --git a/cpp/BUILD b/cpp/BUILD index c39822b5d4..fdf041f19a 100644 --- a/cpp/BUILD +++ b/cpp/BUILD @@ -18,6 +18,7 @@ cc_library( strip_include_prefix = "include/", deps = [ "//core", + "//core/ir", "//core/util:prelude", ], alwayslink = True, diff --git a/cpp/src/compile_spec.cpp b/cpp/src/compile_spec.cpp index e598298f4f..e0ba2c719d 100644 --- a/cpp/src/compile_spec.cpp +++ b/cpp/src/compile_spec.cpp @@ -286,7 +286,13 @@ CompileSpec::Input::Input(at::Tensor tensor) { /* ==========================================*/ core::ir::Input to_internal_input(CompileSpec::Input& i) { - return core::ir::Input(i.min_shape, i.opt_shape, i.max_shape, toTRTDataType(i.dtype), toTRTTensorFormat(i.format)); + return core::ir::Input( + i.min_shape, + i.opt_shape, + i.max_shape, + toTRTDataType(i.dtype), + toTRTTensorFormat(i.format), + i.get_explicit_set_dtype()); } std::vector to_vec_internal_inputs(std::vector& external) { @@ -317,21 +323,20 @@ core::CompileSpec to_internal_compile_spec(CompileSpec external) { internal.convert_info.engine_settings.enabled_precisions.insert(toTRTDataType(p)); } - /* We want default behavior for types to match PyTorch, so in the case the user did not explicitly set the dtype for - inputs they will follow PyTorch convetions */ - for (size_t i = 0; i < external.inputs.size(); i++) { - if (!external.inputs[i].get_explicit_set_dtype()) { - auto& precisions = internal.convert_info.engine_settings.enabled_precisions; - auto& internal_ins = internal.convert_info.inputs; - if (precisions.find(nvinfer1::DataType::kINT8) != precisions.end()) { - internal_ins[i].dtype = nvinfer1::DataType::kFLOAT; - } else if (precisions.find(nvinfer1::DataType::kHALF) != precisions.end()) { - internal_ins[i].dtype = nvinfer1::DataType::kHALF; - } else { - internal_ins[i].dtype = nvinfer1::DataType::kFLOAT; - } - } - } + // /* We want default behavior for types to match PyTorch, so in the case the user did not explicitly set the dtype + // for inputs they will follow PyTorch convetions */ for (size_t i = 0; i < external.inputs.size(); i++) { + // if (!external.inputs[i].get_explicit_set_dtype()) { + // auto& precisions = internal.convert_info.engine_settings.enabled_precisions; + // auto& internal_ins = internal.convert_info.inputs; + // if (precisions.find(nvinfer1::DataType::kINT8) != precisions.end()) { + // internal_ins[i].dtype = nvinfer1::DataType::kFLOAT; + // } else if (precisions.find(nvinfer1::DataType::kHALF) != precisions.end()) { + // internal_ins[i].dtype = nvinfer1::DataType::kHALF; + // } else { + // internal_ins[i].dtype = nvinfer1::DataType::kFLOAT; + // } + // } + // } internal.convert_info.engine_settings.sparse_weights = external.sparse_weights; internal.convert_info.engine_settings.disable_tf32 = external.disable_tf32; diff --git a/tests/core/BUILD b/tests/core/BUILD index b1f7d119bb..ab0d46f7d1 100644 --- a/tests/core/BUILD +++ b/tests/core/BUILD @@ -3,6 +3,6 @@ test_suite( tests = [ "//tests/core/conversion:conversion_tests", "//tests/core/lowering:lowering_tests", - "//tests/core/partitioning:partitioning_test" + "//tests/core/partitioning:partitioning_tests" ], ) diff --git a/tests/core/conversion/converters/test_activation.cpp b/tests/core/conversion/converters/test_activation.cpp index 736a7fe112..f78ff87e54 100644 --- a/tests/core/conversion/converters/test_activation.cpp +++ b/tests/core/conversion/converters/test_activation.cpp @@ -14,11 +14,11 @@ TEST(Converters, ATenReLUConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(-5, 5, {5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -34,11 +34,11 @@ TEST(Converters, ATenSigmoidConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(-5, 5, {5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 5e-6)); @@ -54,11 +54,11 @@ TEST(Converters, ATenTanhConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(-5, 5, {5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 7e-6)); @@ -78,11 +78,11 @@ TEST(Converters, ATenHardTanhConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(-5, 5, {5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -100,11 +100,11 @@ TEST(Converters, ATenHardTanhCustomRangeConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(-5, 5, {5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -123,11 +123,11 @@ TEST(Converters, ATenPReLUConvertsCorrectly) { auto in = at::randint(-5, 5, {5}, {at::kCUDA}); auto slope = at::randint(-5, 5, {1}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {slope}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {slope}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {slope}); + params = trtorch::core::ir::get_static_params(g->inputs(), {slope}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -146,11 +146,11 @@ TEST(Converters, ATenPReLUMultiChannelConvertsCorrectly) { auto in = at::randint(-5, 5, {1, 10, 1, 1}, {at::kCUDA}); auto slope = at::randint(-5, 5, {10}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {slope}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {slope}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {slope}); + params = trtorch::core::ir::get_static_params(g->inputs(), {slope}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -167,11 +167,11 @@ TEST(Converters, ATenLeakyReluConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(-5, 5, {5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -190,11 +190,11 @@ TEST(Converters, ATenEluConvertsCorrectly) { auto in = at::randint(-5, 5, {1, 10, 1, 1}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -211,11 +211,11 @@ TEST(Converters, ATenGELUConvertsCorrectly) { auto in = at::randint(-5, 5, {5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); // NOTE: The official tensorrt plugin applies the Gelu activation x * Phi(x), where Phi is the Gaussian cdf, diff --git a/tests/core/conversion/converters/test_batch_norm.cpp b/tests/core/conversion/converters/test_batch_norm.cpp index 6ef9c55a3b..e025364d12 100644 --- a/tests/core/conversion/converters/test_batch_norm.cpp +++ b/tests/core/conversion/converters/test_batch_norm.cpp @@ -26,10 +26,10 @@ TEST(Converters, ATenBatchNormConvertsCorrectly) { auto mean = at::randint(1, 10, {5}, {at::kCUDA}); auto var = at::randint(1, 10, {5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {gamma, beta, mean, var}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {gamma, beta, mean, var}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {gamma, beta, mean, var}); + params = trtorch::core::ir::get_static_params(g->inputs(), {gamma, beta, mean, var}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -63,10 +63,10 @@ TEST(Converters, ATenBatchNormShouldUnpackConvertsCorrectly) { auto trt_mean = at::clone(mean); auto trt_var = at::clone(var); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {gamma, beta, mean, var}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {gamma, beta, mean, var}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_gamma, trt_beta, trt_mean, trt_var}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_gamma, trt_beta, trt_mean, trt_var}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); diff --git a/tests/core/conversion/converters/test_cast.cpp b/tests/core/conversion/converters/test_cast.cpp index ea3f171937..829097abf0 100644 --- a/tests/core/conversion/converters/test_cast.cpp +++ b/tests/core/conversion/converters/test_cast.cpp @@ -25,11 +25,11 @@ TEST(Converters, ATenBoolToFP32DTypeConvertsCorrectly) { auto in = at::randint(1, 10, {3, 4, 3}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -56,11 +56,11 @@ TEST(Converters, ATenBoolToINT32DTypeConvertsCorrectly) { auto in = at::randint(1, 10, {3, 4, 3}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -87,11 +87,11 @@ TEST(Converters, ATenBoolToINT32DeviceDTypeConvertsCorrectly) { auto in = at::randint(1, 10, {3, 4, 3}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -122,12 +122,12 @@ TEST(Converters, ATenBoolToINT32TensorConvertsCorrectly) { auto jit_in = at::clone(in); auto jit_in2 = at::clone(in2); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in, jit_in2}); auto trt_in = at::clone(in); auto trt_in2 = at::clone(in2); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in, trt_in2}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -154,10 +154,10 @@ TEST(Converters, ATenTypeAsConvertsCorrectly) { // Lower aten::type_as to aten::to.other trtorch::core::lowering::passes::ReduceToOperation(g); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1, in2}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1, in2}); ASSERT_TRUE(jit_results[0].scalar_type() == trt_results[0].scalar_type()); diff --git a/tests/core/conversion/converters/test_clone.cpp b/tests/core/conversion/converters/test_clone.cpp index a8c57970ca..c67ce797b8 100644 --- a/tests/core/conversion/converters/test_clone.cpp +++ b/tests/core/conversion/converters/test_clone.cpp @@ -20,10 +20,10 @@ TEST(Converters, ATenCloneConvertsCorrectly) { auto in = at::randint(1, 10, {1, 3, 10, 10}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); diff --git a/tests/core/conversion/converters/test_concat.cpp b/tests/core/conversion/converters/test_concat.cpp index 7e940df3c0..e1dc382664 100644 --- a/tests/core/conversion/converters/test_concat.cpp +++ b/tests/core/conversion/converters/test_concat.cpp @@ -19,10 +19,10 @@ TEST(Converters, ATenCatPureTensorConvertsCorrectly) { auto in1 = at::randint(1, 10, {5}, {at::kCUDA}); auto in2 = at::randint(1, 10, {5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1, in2}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1, in2}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -43,10 +43,10 @@ TEST(Converters, ATenCatDiffTensorConvertsCorrectly) { auto in1 = at::randint(1, 10, {5}, {at::kCUDA}); auto in2 = at::randint(1, 10, {5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {in2}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {in2}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {in2}); + params = trtorch::core::ir::get_static_params(g->inputs(), {in2}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -66,10 +66,10 @@ TEST(Converters, ATenCatPureTensorNegDimConvertsCorrectly) { auto in1 = at::randint(1, 10, {5, 5}, {at::kCUDA}); auto in2 = at::randint(1, 10, {5, 5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1, in2}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1, in2}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -90,10 +90,10 @@ TEST(Converters, ATenCatDiffTensorNegDimConvertsCorrectly) { auto in1 = at::randint(1, 10, {5, 5}, {at::kCUDA}); auto in2 = at::randint(1, 10, {5, 5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {in2}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {in2}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {in2}); + params = trtorch::core::ir::get_static_params(g->inputs(), {in2}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); diff --git a/tests/core/conversion/converters/test_constant_pad.cpp b/tests/core/conversion/converters/test_constant_pad.cpp index 19e0f0cb4e..63ed8addd5 100644 --- a/tests/core/conversion/converters/test_constant_pad.cpp +++ b/tests/core/conversion/converters/test_constant_pad.cpp @@ -18,10 +18,10 @@ TEST(Converters, ATenConstantPad1dTensorConvertsCorrectly) { auto in1 = at::randint(1, 10, {1, 3, 4}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -40,10 +40,10 @@ TEST(Converters, ATenConstantPad1dRightZeroTensorConvertsCorrectly) { auto in1 = at::randint(1, 10, {1, 3, 4}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -62,10 +62,10 @@ TEST(Converters, ATenConstantPad1dTensorConvertsCorrectlyWithDynamic) { auto in1 = at::randint(1, 10, {1, 3, 4}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -84,10 +84,10 @@ TEST(Converters, ATenConstantPad2dTensorConvertsCorrectly) { auto in1 = at::randint(1, 10, {1, 3, 4, 5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -106,10 +106,10 @@ TEST(Converters, ATenConstantPad2dRightBottomZeroTensorConvertsCorrectly) { auto in1 = at::randint(1, 10, {1, 3, 4, 5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -128,10 +128,10 @@ TEST(Converters, ATenConstantPad2dTensorConvertsCorrectlyWithDynamic) { auto in1 = at::randint(1, 10, {1, 3, 4, 5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -150,10 +150,10 @@ TEST(Converters, ATenConstantPad3dTensorConvertsCorrectly) { auto in1 = at::randint(1, 10, {1, 3, 4, 5, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -171,10 +171,10 @@ TEST(Converters, ATenConstantPad3dRightBottomBackZeroTensorConvertsCorrectly) { auto in1 = at::randint(1, 10, {1, 3, 4, 5, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -193,10 +193,10 @@ TEST(Converters, ATenConstantPad3dTensorConvertsCorrectlyWithDynamic) { auto in1 = at::randint(1, 10, {1, 3, 4, 5, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); diff --git a/tests/core/conversion/converters/test_conv_deconv.cpp b/tests/core/conversion/converters/test_conv_deconv.cpp index 87dd6c2406..272876e497 100644 --- a/tests/core/conversion/converters/test_conv_deconv.cpp +++ b/tests/core/conversion/converters/test_conv_deconv.cpp @@ -22,13 +22,13 @@ void conv_test_helper(std::string graph_ir) { auto jit_w = at::clone(w); auto jit_b = at::clone(b); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {jit_w, jit_b}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {jit_w, jit_b}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); auto trt_w = at::clone(w); auto trt_b = at::clone(b); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_w, trt_b}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_w, trt_b}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -64,13 +64,13 @@ TEST(Converters, ATenConvolutionConvertsCorrectly) { auto jit_w = at::clone(w); auto jit_b = at::clone(b); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {jit_w, jit_b}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {jit_w, jit_b}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); auto trt_w = at::clone(w); auto trt_b = at::clone(b); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_w, trt_b}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_w, trt_b}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -103,12 +103,12 @@ TEST(Converters, ATenConvolution1dConvertsCorrectly) { auto jit_in = at::clone(in); auto jit_w = at::clone(w); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {jit_w}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {jit_w}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); auto trt_w = at::clone(w); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_w}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_w}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -141,12 +141,12 @@ TEST(Converters, ATenConvolutionNoBiasConvertsCorrectly) { auto jit_in = at::clone(in); auto jit_w = at::clone(w); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {jit_w}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {jit_w}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); auto trt_w = at::clone(w); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_w}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_w}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -183,13 +183,13 @@ TEST(Converters, ATenConvolutionWithStrideConvertsCorrectly) { auto jit_w = at::clone(w); auto jit_b = at::clone(b); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {jit_w, jit_b}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {jit_w, jit_b}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); auto trt_w = at::clone(w); auto trt_b = at::clone(b); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_w, trt_b}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_w, trt_b}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -226,13 +226,13 @@ TEST(Converters, ATenConvolutionWithPaddingConvertsCorrectly) { auto jit_w = at::clone(w); auto jit_b = at::clone(b); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {jit_w, jit_b}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {jit_w, jit_b}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); auto trt_w = at::clone(w); auto trt_b = at::clone(b); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_w, trt_b}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_w, trt_b}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -268,13 +268,13 @@ TEST(Converters, ATenConvolution3dConvertsCorrectly) { auto jit_w = at::clone(w); auto jit_b = at::clone(b); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {jit_w, jit_b}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {jit_w, jit_b}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); auto trt_w = at::clone(w); auto trt_b = at::clone(b); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_w, trt_b}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_w, trt_b}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -307,12 +307,12 @@ TEST(Converters, ATenConvolution3dNoBiasConvertsCorrectly) { auto jit_in = at::clone(in); auto jit_w = at::clone(w); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {jit_w}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {jit_w}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); auto trt_w = at::clone(w); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_w}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_w}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -348,13 +348,13 @@ TEST(Converters, ATenConvolution3dWithPaddingConvertsCorrectly) { auto jit_w = at::clone(w); auto jit_b = at::clone(b); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {jit_w, jit_b}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {jit_w, jit_b}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); auto trt_w = at::clone(w); auto trt_b = at::clone(b); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_w, trt_b}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_w, trt_b}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -390,13 +390,13 @@ TEST(Converters, ATenConvolution3dWithStrideDilationConvertsCorrectly) { auto jit_w = at::clone(w); auto jit_b = at::clone(b); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {jit_w, jit_b}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {jit_w, jit_b}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); auto trt_w = at::clone(w); auto trt_b = at::clone(b); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_w, trt_b}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_w, trt_b}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -432,13 +432,13 @@ TEST(Converters, ATenConvTransposeConvertsCorrectly) { auto jit_w = at::clone(w); auto jit_b = at::clone(b); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {jit_w, jit_b}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {jit_w, jit_b}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); auto trt_w = at::clone(w); auto trt_b = at::clone(b); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_w, trt_b}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_w, trt_b}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -471,12 +471,12 @@ TEST(Converters, ATenConvTransposeNoBiasConvertsCorrectly) { auto jit_in = at::clone(in); auto jit_w = at::clone(w); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {jit_w}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {jit_w}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); auto trt_w = at::clone(w); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_w}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_w}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -513,13 +513,13 @@ TEST(Converters, ATenConvTransposeWithStrideConvertsCorrectly) { auto jit_w = at::clone(w); auto jit_b = at::clone(b); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {jit_w, jit_b}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {jit_w, jit_b}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); auto trt_w = at::clone(w); auto trt_b = at::clone(b); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_w, trt_b}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_w, trt_b}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -556,13 +556,13 @@ TEST(Converters, ATenConvTransposeWithPaddingConvertsCorrectly) { auto jit_w = at::clone(w); auto jit_b = at::clone(b); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {jit_w, jit_b}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {jit_w, jit_b}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); auto trt_w = at::clone(w); auto trt_b = at::clone(b); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_w, trt_b}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_w, trt_b}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -599,13 +599,13 @@ TEST(Converters, ATenConvolutionWithGroupConvertsCorrectly) { auto jit_w = at::clone(w); auto jit_b = at::clone(b); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {jit_w, jit_b}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {jit_w, jit_b}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); auto trt_w = at::clone(w); auto trt_b = at::clone(b); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_w, trt_b}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_w, trt_b}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -642,13 +642,13 @@ TEST(Converters, ATenConvTransposeWithGroupConvertsCorrectly) { auto jit_w = at::clone(w); auto jit_b = at::clone(b); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {jit_w, jit_b}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {jit_w, jit_b}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); auto trt_w = at::clone(w); auto trt_b = at::clone(b); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_w, trt_b}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_w, trt_b}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); diff --git a/tests/core/conversion/converters/test_copy.cpp b/tests/core/conversion/converters/test_copy.cpp index 0f6c548d2f..062f025178 100644 --- a/tests/core/conversion/converters/test_copy.cpp +++ b/tests/core/conversion/converters/test_copy.cpp @@ -28,10 +28,10 @@ TEST(Converters, ATenCopyConvertsCorrectly) { auto in = at::randint(1, 10, {1, 3, 10, 10}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); diff --git a/tests/core/conversion/converters/test_cumsum.cpp b/tests/core/conversion/converters/test_cumsum.cpp index dbb53f63ea..702afb1b50 100644 --- a/tests/core/conversion/converters/test_cumsum.cpp +++ b/tests/core/conversion/converters/test_cumsum.cpp @@ -16,11 +16,11 @@ TEST(Converters, ATenCumsumConvertsCorrectly) { torch::jit::parseIR(graph, &*g); auto in = at::randint(-5, 5, {2, 3, 4}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -38,11 +38,11 @@ TEST(Converters, ATenCumsumConvertsCorrectlyWithDynamicInput) { torch::jit::parseIR(graph, &*g); auto in = at::randint(-5, 5, {2, 3, 4}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -60,11 +60,11 @@ TEST(Converters, ATenCumsumNegativeDimConvertsCorrectly) { torch::jit::parseIR(graph, &*g); auto in = at::randint(-5, 5, {2, 3, 4}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -82,11 +82,11 @@ TEST(Converters, ATenCumsumNegativeDimConvertsCorrectlyWithDynamicInput) { torch::jit::parseIR(graph, &*g); auto in = at::randint(-5, 5, {2, 3, 4}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); diff --git a/tests/core/conversion/converters/test_element_wise.cpp b/tests/core/conversion/converters/test_element_wise.cpp index 18cabe8120..fcba3c2177 100644 --- a/tests/core/conversion/converters/test_element_wise.cpp +++ b/tests/core/conversion/converters/test_element_wise.cpp @@ -20,7 +20,7 @@ void pointwise_test_helper( if (!singleInput) { torch_inputs.push_back(at::randint(1, 5, shape2, {at::kCUDA})); } - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, torch_inputs); std::vector trt_inputs; @@ -28,7 +28,7 @@ void pointwise_test_helper( trt_inputs.push_back(at::clone(in)); } - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); std::vector trt_results; if (dynamicInput) { trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, trt_inputs); diff --git a/tests/core/conversion/converters/test_expand.cpp b/tests/core/conversion/converters/test_expand.cpp index ec2d22a81c..ac27b931b0 100644 --- a/tests/core/conversion/converters/test_expand.cpp +++ b/tests/core/conversion/converters/test_expand.cpp @@ -20,11 +20,11 @@ TEST(Converters, ATenExpandSameDimConvertsCorrectly) { auto in = at::randint(1, 10, {3, 1}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -47,11 +47,11 @@ TEST(Converters, ATenExpandSameDimConvertsCorrectlyWithDynamicInput) { auto in = at::randint(1, 10, {3, 1}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -74,11 +74,11 @@ TEST(Converters, ATenExpandTileConvertsCorrectly) { auto in = at::randint(1, 10, {3, 1}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -101,11 +101,11 @@ TEST(Converters, ATenExpandTileConvertsCorrectlyWithDynamicInput) { auto in = at::randint(1, 10, {3, 1}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -128,11 +128,11 @@ TEST(Converters, ATenExpandTileLastConvertsCorrectly) { auto in = at::randint(1, 10, {3, 1}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -155,11 +155,11 @@ TEST(Converters, ATenExpandTileLastConvertsCorrectlyWithDynamicInput) { auto in = at::randint(1, 10, {3, 1}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -182,11 +182,11 @@ TEST(Converters, ATenExpandNegativeSizeConvertsCorrectly) { auto in = at::randint(1, 10, {3, 1}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -209,11 +209,11 @@ TEST(Converters, ATenExpandNegativeSizeConvertsCorrectlyWithDynamicInput) { auto in = at::randint(1, 10, {3, 1}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -245,12 +245,12 @@ TEST(Converters, ATenExpandASConvertsCorrectly) { auto jit_in = at::clone(in); auto jit_target_in = at::clone(target_in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in, jit_target_in}); auto trt_in = at::clone(jit_in); auto trt_target_in = at::clone(jit_target_in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in, trt_target_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -277,12 +277,12 @@ TEST(Converters, ATenExpandAsConvertsCorrectlyWithDynamicInput) { auto jit_in = at::clone(in); auto jit_target_in = at::clone(target_in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in, jit_target_in}); auto trt_in = at::clone(jit_in); auto trt_target_in = at::clone(jit_target_in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {trt_in, trt_target_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -304,11 +304,11 @@ TEST(Converters, ATenRepeatConvertsCorrectly) { auto in = at::randint(1, 10, {1, 3}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(jit_in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -330,11 +330,11 @@ TEST(Converters, ATenRepeatConvertsCorrectlyWithDynamicInput) { auto in = at::randint(1, 10, {1, 3}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(jit_in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -356,11 +356,11 @@ TEST(Converters, ATenRepeat3dConvertsCorrectly) { auto in = at::randint(1, 10, {2, 3, 2}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(jit_in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -382,11 +382,11 @@ TEST(Converters, ATenRepeat3dConvertsCorrectlyWithDynamicInput) { auto in = at::randint(1, 10, {2, 3, 2}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(jit_in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -408,11 +408,11 @@ TEST(Converters, ATenRepeatExtraDimsConvertsCorrectly) { auto in = at::randint(1, 10, {1, 3}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(jit_in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -434,11 +434,11 @@ TEST(Converters, ATenRepeatExtraDimsConvertsCorrectlyWithDynamicInput) { auto in = at::randint(1, 10, {1, 3}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(jit_in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); diff --git a/tests/core/conversion/converters/test_instance_norm.cpp b/tests/core/conversion/converters/test_instance_norm.cpp index 1df8d45d66..e0d2c92962 100644 --- a/tests/core/conversion/converters/test_instance_norm.cpp +++ b/tests/core/conversion/converters/test_instance_norm.cpp @@ -40,11 +40,11 @@ TEST(Converters, ATenInstanceNormConvertsCorrectly) { auto trt_in = at::clone(in); torch::jit::IValue trt_weight, trt_bias, trt_mean, trt_var; - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {weight, bias, mean, var, use_input_stats}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {weight, bias, mean, var, use_input_stats}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params( - g->inputs(), {trt_weight, trt_bias, trt_mean, trt_var, use_input_stats}); + params = + trtorch::core::ir::get_static_params(g->inputs(), {trt_weight, trt_bias, trt_mean, trt_var, use_input_stats}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -67,11 +67,11 @@ TEST(Converters, ATenInstanceNormAffineConvertsCorrectly) { auto trt_bias = at::clone(bias); torch::jit::IValue trt_mean, trt_var; - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {weight, bias, mean, var, use_input_stats}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {weight, bias, mean, var, use_input_stats}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params( - g->inputs(), {trt_weight, trt_bias, trt_mean, trt_var, use_input_stats}); + params = + trtorch::core::ir::get_static_params(g->inputs(), {trt_weight, trt_bias, trt_mean, trt_var, use_input_stats}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -93,11 +93,11 @@ TEST(Converters, ATenInstanceNormRunningStatsConvertsCorrectly) { auto trt_mean = at::clone(mean); auto trt_var = at::clone(var); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {weight, bias, mean, var, use_input_stats}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {weight, bias, mean, var, use_input_stats}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params( - g->inputs(), {trt_weight, trt_bias, trt_mean, trt_var, use_input_stats}); + params = + trtorch::core::ir::get_static_params(g->inputs(), {trt_weight, trt_bias, trt_mean, trt_var, use_input_stats}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); } diff --git a/tests/core/conversion/converters/test_interpolate.cpp b/tests/core/conversion/converters/test_interpolate.cpp index 6f6d2fd5f1..cbf2cdbc08 100644 --- a/tests/core/conversion/converters/test_interpolate.cpp +++ b/tests/core/conversion/converters/test_interpolate.cpp @@ -13,11 +13,11 @@ \ auto in = at::randint(1, 10, input_shape, {at::kCUDA}); \ auto jit_in = at::clone(in); \ - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); \ + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); \ auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); \ \ auto trt_in = at::clone(in); \ - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); \ + params = trtorch::core::ir::get_static_params(g->inputs(), {}); \ \ auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); \ auto trt = trt_results[0].reshape(jit_results[0].sizes()); \ @@ -32,11 +32,11 @@ \ auto in = at::randint(1, 10, input_shape, {at::kCUDA}); \ auto jit_in = at::clone(in); \ - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); \ + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); \ auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); \ \ auto trt_in = at::clone(in); \ - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); \ + params = trtorch::core::ir::get_static_params(g->inputs(), {}); \ \ auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {trt_in}); \ auto trt = trt_results[0].reshape(jit_results[0].sizes()); \ @@ -52,11 +52,11 @@ \ auto in = at::randint(1, 10, input_shape, {at::kCUDA}); \ auto jit_in = at::clone(in); \ - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); \ + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); \ auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); \ \ auto trt_in = at::clone(in); \ - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); \ + params = trtorch::core::ir::get_static_params(g->inputs(), {}); \ \ auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); \ auto trt = trt_results[0].reshape(jit_results[0].sizes()); \ diff --git a/tests/core/conversion/converters/test_layer_norm.cpp b/tests/core/conversion/converters/test_layer_norm.cpp index f3314c2180..c72e4b0e88 100644 --- a/tests/core/conversion/converters/test_layer_norm.cpp +++ b/tests/core/conversion/converters/test_layer_norm.cpp @@ -23,10 +23,10 @@ TEST(Converters, ATenLayerNormConvertsCorrectlyLast3DimsNoGammaBeta) { auto in = at::randint(1, 10, {4, 3, 100, 100}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -53,10 +53,10 @@ TEST(Converters, ATenLayerNormConvertsCorrectlyLast3Dims) { auto gamma = at::randint(1, 10, {3, 100, 100}, {at::kCUDA}); auto beta = at::randint(1, 10, {3, 100, 100}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {gamma, beta}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {gamma, beta}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {gamma, beta}); + params = trtorch::core::ir::get_static_params(g->inputs(), {gamma, beta}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -82,10 +82,10 @@ TEST(Converters, ATenLayerNormConvertsCorrectlyLast2Dims) { auto gamma = at::randint(1, 10, {100, 100}, {at::kCUDA}); auto beta = at::randint(1, 10, {100, 100}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {gamma, beta}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {gamma, beta}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {gamma, beta}); + params = trtorch::core::ir::get_static_params(g->inputs(), {gamma, beta}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -110,10 +110,10 @@ TEST(Converters, ATenLayerNormConvertsCorrectlyLast1Dims) { auto gamma = at::randint(1, 10, {100}, {at::kCUDA}); auto beta = at::randint(1, 10, {100}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {gamma, beta}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {gamma, beta}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {gamma, beta}); + params = trtorch::core::ir::get_static_params(g->inputs(), {gamma, beta}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -138,10 +138,10 @@ TEST(Converters, ATenLayerNormConvertsCorrectly3dInput1dNormalizedShape) { auto gamma = at::randint(1, 10, {768}, {at::kCUDA}); auto beta = at::randint(1, 10, {768}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {gamma, beta}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {gamma, beta}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {gamma, beta}); + params = trtorch::core::ir::get_static_params(g->inputs(), {gamma, beta}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); diff --git a/tests/core/conversion/converters/test_linear.cpp b/tests/core/conversion/converters/test_linear.cpp index 6a5397d69c..897108ec25 100644 --- a/tests/core/conversion/converters/test_linear.cpp +++ b/tests/core/conversion/converters/test_linear.cpp @@ -19,12 +19,12 @@ TEST(Converters, ATenLinearNoBiasConvertsCorrectly) { auto in = at::randint(1, 10, {1, 2}, {at::kCUDA}); auto w = at::randint(1, 10, {3, 2}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {w}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {w}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); w = at::clone(w); - params = trtorch::core::conversion::get_named_params(g->inputs(), {w}); + params = trtorch::core::ir::get_static_params(g->inputs(), {w}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -51,13 +51,13 @@ TEST(Converters, ATenLinearBiasConvertsCorrectly) { auto jit_w = at::clone(w); auto jit_b = at::clone(b); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {jit_w, jit_b}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {jit_w, jit_b}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); auto trt_w = at::clone(w); auto trt_b = at::clone(b); - params = trtorch::core::conversion::get_named_params(g->inputs(), {trt_w, trt_b}); + params = trtorch::core::ir::get_static_params(g->inputs(), {trt_w, trt_b}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); diff --git a/tests/core/conversion/converters/test_lstm_cell.cpp b/tests/core/conversion/converters/test_lstm_cell.cpp index c1184824c5..74204aa79a 100644 --- a/tests/core/conversion/converters/test_lstm_cell.cpp +++ b/tests/core/conversion/converters/test_lstm_cell.cpp @@ -32,7 +32,7 @@ TEST(Converters, ATenGRUCellConvertsCorrectlyWithBiasCheckHidden) { auto jit_b_ih = at::clone(b_ih); auto jit_b_hh = at::clone(b_hh); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_input, jit_h0, jit_w_ih, jit_w_hh, jit_b_ih, jit_b_hh}); @@ -43,7 +43,7 @@ TEST(Converters, ATenGRUCellConvertsCorrectlyWithBiasCheckHidden) { auto trt_b_ih = at::clone(b_ih); auto trt_b_hh = at::clone(b_hh); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_input, trt_h0, trt_w_ih, trt_w_hh, trt_b_ih, trt_b_hh}); @@ -74,7 +74,7 @@ TEST(Converters, ATenGRUCellConvertsCorrectlyWithoutBiasCheckHidden) { auto jit_w_ih = at::clone(w_ih); auto jit_w_hh = at::clone(w_hh); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_input, jit_h0, jit_w_ih, jit_w_hh}); auto trt_input = at::clone(input); @@ -82,7 +82,7 @@ TEST(Converters, ATenGRUCellConvertsCorrectlyWithoutBiasCheckHidden) { auto trt_w_ih = at::clone(w_ih); auto trt_w_hh = at::clone(w_hh); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_input, trt_h0, trt_w_ih, trt_w_hh}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-5)); @@ -120,7 +120,7 @@ TEST(Converters, ATenLSTMCellConvertsCorrectlyWithBiasCheckHidden) { auto jit_b_ih = at::clone(b_ih); auto jit_b_hh = at::clone(b_hh); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_input, jit_h0, jit_c0, jit_w_ih, jit_w_hh, jit_b_ih, jit_b_hh}); @@ -132,7 +132,7 @@ TEST(Converters, ATenLSTMCellConvertsCorrectlyWithBiasCheckHidden) { auto trt_b_ih = at::clone(b_ih); auto trt_b_hh = at::clone(b_hh); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine( g, params, {trt_input, trt_h0, trt_c0, trt_w_ih, trt_w_hh, trt_b_ih, trt_b_hh}); @@ -171,7 +171,7 @@ TEST(Converters, ATenLSTMCellConvertsCorrectlyWithBiasCheckCell) { auto jit_b_ih = at::clone(b_ih); auto jit_b_hh = at::clone(b_hh); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_input, jit_h0, jit_c0, jit_w_ih, jit_w_hh, jit_b_ih, jit_b_hh}); @@ -183,7 +183,7 @@ TEST(Converters, ATenLSTMCellConvertsCorrectlyWithBiasCheckCell) { auto trt_b_ih = at::clone(b_ih); auto trt_b_hh = at::clone(b_hh); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine( g, params, {trt_input, trt_h0, trt_c0, trt_w_ih, trt_w_hh, trt_b_ih, trt_b_hh}); @@ -218,7 +218,7 @@ TEST(Converters, ATenLSTMCellConvertsCorrectlyWithoutBiasCheckHidden) { auto jit_w_ih = at::clone(w_ih); auto jit_w_hh = at::clone(w_hh); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_input, jit_h0, jit_c0, jit_w_ih, jit_w_hh}); auto trt_input = at::clone(input); @@ -227,7 +227,7 @@ TEST(Converters, ATenLSTMCellConvertsCorrectlyWithoutBiasCheckHidden) { auto trt_w_ih = at::clone(w_ih); auto trt_w_hh = at::clone(w_hh); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_input, trt_h0, trt_c0, trt_w_ih, trt_w_hh}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-5)); @@ -261,7 +261,7 @@ TEST(Converters, ATenLSTMCellConvertsCorrectlyWithoutBiasCheckCell) { auto jit_w_ih = at::clone(w_ih); auto jit_w_hh = at::clone(w_hh); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_input, jit_h0, jit_c0, jit_w_ih, jit_w_hh}); auto trt_input = at::clone(input); @@ -270,7 +270,7 @@ TEST(Converters, ATenLSTMCellConvertsCorrectlyWithoutBiasCheckCell) { auto trt_w_ih = at::clone(w_ih); auto trt_w_hh = at::clone(w_hh); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_input, trt_h0, trt_c0, trt_w_ih, trt_w_hh}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-5)); diff --git a/tests/core/conversion/converters/test_matrix_multiply.cpp b/tests/core/conversion/converters/test_matrix_multiply.cpp index 22cbc57c2c..564f940a21 100644 --- a/tests/core/conversion/converters/test_matrix_multiply.cpp +++ b/tests/core/conversion/converters/test_matrix_multiply.cpp @@ -16,10 +16,10 @@ TEST(Converters, ATenMMConvertsCorrectly) { auto in1 = at::randint(0, 5, {2, 3}, {at::kCUDA}); auto in2 = at::randint(0, 5, {3, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1, in2}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1, in2}); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -37,10 +37,10 @@ TEST(Converters, ATenMMWithDiffShapesConvertsCorrectly) { auto in1 = at::randint(0, 5, {2, 3}, {at::kCUDA}); auto in2 = at::randint(0, 5, {3, 3, 2}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1, in2}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1, in2}); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -58,10 +58,10 @@ TEST(Converters, ATenBMMConvertsCorrectly) { auto in1 = at::randint(0, 5, {4, 64, 128}, {at::kCUDA}); auto in2 = at::randint(0, 5, {4, 128, 64}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1, in2}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1, in2}); auto trt = trt_results[0].reshape_as(jit_results[0]); diff --git a/tests/core/conversion/converters/test_normalize.cpp b/tests/core/conversion/converters/test_normalize.cpp index a0c9a623c4..b31f792a1b 100644 --- a/tests/core/conversion/converters/test_normalize.cpp +++ b/tests/core/conversion/converters/test_normalize.cpp @@ -13,11 +13,11 @@ \ auto in = at::randint(1, 10, input_shape, {at::kCUDA}); \ auto jit_in = at::clone(in); \ - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); \ + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); \ auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); \ \ auto trt_in = at::clone(in); \ - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); \ + params = trtorch::core::ir::get_static_params(g->inputs(), {}); \ \ auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); \ auto trt = trt_results[0].reshape(jit_results[0].sizes()); \ @@ -32,11 +32,11 @@ \ auto in = at::randint(1, 10, input_shape, {at::kCUDA}); \ auto jit_in = at::clone(in); \ - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); \ + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); \ auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); \ \ auto trt_in = at::clone(in); \ - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); \ + params = trtorch::core::ir::get_static_params(g->inputs(), {}); \ \ auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {trt_in}); \ auto trt = trt_results[0].reshape(jit_results[0].sizes()); \ diff --git a/tests/core/conversion/converters/test_pooling.cpp b/tests/core/conversion/converters/test_pooling.cpp index b804bdc0d2..cebdb6ef8e 100644 --- a/tests/core/conversion/converters/test_pooling.cpp +++ b/tests/core/conversion/converters/test_pooling.cpp @@ -21,11 +21,11 @@ TEST(Converters, ATenMaxPool1DConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(-5, 5, {1, 1, 10}, at::kCUDA); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -48,11 +48,11 @@ TEST(Converters, ATenMaxPool1DConvertsCorrectlyWithDynamicInput) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(-5, 5, {1, 1, 10}, at::kCUDA); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {in}, true); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -76,11 +76,11 @@ TEST(Converters, ATenMaxPool2DConvertsCorrectly) { // PyTorch MaxPool needs a 3D input auto in = at::randint(-5, 5, {1, 10, 10}, at::kCUDA); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -104,11 +104,11 @@ TEST(Converters, ATenMaxPool2DConvertsCorrectlyWithDynamicInput) { // PyTorch MaxPool needs a 3D input auto in = at::randint(-5, 5, {1, 10, 10}, at::kCUDA); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {in}, false); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -132,11 +132,11 @@ TEST(Converters, ATenMaxPool3DConvertsCorrectly) { // PyTorch MaxPool needs a 3D input auto in = at::randint(-5, 5, {1, 3, 10, 10, 10}, at::kCUDA); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -162,11 +162,11 @@ TEST(Converters, ATenAvgPool1DConvertsCorrectly) { // PyTorch AvgPool needs a 3D input auto in = at::randint(-5, 5, {1, 1, 10}, at::kCUDA); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -191,11 +191,11 @@ TEST(Converters, ATenAvgPool1DCeilConvertsCorrectly) { // PyTorch AvgPool needs a 3D input auto in = at::randint(-5, 5, {1, 1, 4}, at::kCUDA); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -220,11 +220,11 @@ TEST(Converters, ATenAvgPool1DNoCountPadConvertsCorrectly) { // PyTorch AvgPool needs a 3D input auto in = at::randint(-5, 5, {1, 1, 4}, at::kCUDA); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -250,11 +250,11 @@ TEST(Converters, ATenAvgPool2DConvertsCorrectly) { // PyTorch AvgPool needs a 3D input auto in = at::randint(-5, 5, {1, 4, 4}, at::kCUDA); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -280,11 +280,11 @@ TEST(Converters, ATenAvgPool2DCeilConvertsCorrectly) { // PyTorch AvgPool needs a 3D input auto in = at::randint(-5, 5, {1, 4, 4}, at::kCUDA); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -310,11 +310,11 @@ TEST(Converters, ATenAvgPool2DNoCountPadConvertsCorrectly) { // PyTorch AvgPool needs a 3D input auto in = at::randint(-5, 5, {1, 4, 4}, at::kCUDA); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -340,11 +340,11 @@ TEST(Converters, ATenAvgPool3DConvertsCorrectly) { // PyTorch AvgPool needs a 3D input auto in = at::randint(-5, 5, {1, 3, 4, 4, 4}, at::kCUDA); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -370,11 +370,11 @@ TEST(Converters, ATenAvgPool3DCeilConvertsCorrectly) { // PyTorch AvgPool needs a 3D input auto in = at::randint(-5, 5, {1, 3, 4, 4, 4}, at::kCUDA); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -400,11 +400,11 @@ TEST(Converters, ATenAvgPool3DNoCountPadConvertsCorrectly) { // PyTorch AvgPool needs a 3D input auto in = at::randint(-5, 5, {1, 3, 4, 4, 4}, at::kCUDA); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -426,11 +426,11 @@ TEST(Converters, ATenAdaptiveAvgPool2DConvertsCorrectly) { auto in = at::randint(-5, 5, {512, 32, 32}, at::kCUDA); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -452,11 +452,11 @@ TEST(Converters, ATenAdaptiveAvgPool2DConvertsCorrectlyWithDynamicInput) { auto in = at::randint(-5, 5, {512, 32, 32}, at::kCUDA); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {trt_in}, false); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -478,11 +478,11 @@ TEST(Converters, ATenAdaptiveAvgPool1DConvertsCorrectly) { auto in = at::randint(-5, 5, {1, 3, 16}, at::kCUDA); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 1.0)); @@ -504,11 +504,11 @@ TEST(Converters, ATenAdaptiveMaxPool2DConvertsCorrectly) { auto in = at::randint(-5, 5, {512, 32, 32}, at::kCUDA); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -530,11 +530,11 @@ TEST(Converters, ATenAdaptiveMaxPool2DConvertsCorrectlyWithDynamicInput) { auto in = at::rand({512, 32, 32}, at::kCUDA); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {trt_in}, false); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); diff --git a/tests/core/conversion/converters/test_quantization.cpp b/tests/core/conversion/converters/test_quantization.cpp index 0666f15f81..71f5e7677a 100644 --- a/tests/core/conversion/converters/test_quantization.cpp +++ b/tests/core/conversion/converters/test_quantization.cpp @@ -20,10 +20,10 @@ TEST(Converters, ATenFakeQuantizePerTensorConvertsCorrectly) { auto in = at::randint(1, 10, {1, 5, 5, 5}, {at::kCUDA}).to(at::kFloat); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}, nvinfer1::DataType::kINT8); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -53,10 +53,10 @@ TEST(Converters, ATenFakeQuantizePerChannelConvertsCorrectly) { auto in = at::randint(1, 10, {1, 5, 3, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}, nvinfer1::DataType::kINT8); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); diff --git a/tests/core/conversion/converters/test_reduce.cpp b/tests/core/conversion/converters/test_reduce.cpp index 3ad39d46c8..d0fc8c1253 100644 --- a/tests/core/conversion/converters/test_reduce.cpp +++ b/tests/core/conversion/converters/test_reduce.cpp @@ -65,11 +65,11 @@ void test_body(const std::string& graph, at::Tensor& in) { auto g = std::make_shared(); torch::jit::parseIR(graph, g.get()); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); } @@ -279,13 +279,13 @@ TEST(Converters, UnpackVarLowersCorrectly) { auto g = std::make_shared(); torch::jit::parseIR(graph, g.get()); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); trtorch::core::lowering::passes::UnpackVar(g); torch::jit::EliminateCommonSubexpression(g); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); } @@ -305,13 +305,13 @@ TEST(Converters, UnpackVarKeepDimsLowersCorrectly) { auto g = std::make_shared(); torch::jit::parseIR(graph, g.get()); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); trtorch::core::lowering::passes::UnpackVar(g); torch::jit::EliminateCommonSubexpression(g); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); } @@ -331,13 +331,13 @@ TEST(Converters, UnpackVarUnbiasedLowersCorrectly) { auto g = std::make_shared(); torch::jit::parseIR(graph, g.get()); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); trtorch::core::lowering::passes::UnpackVar(g); torch::jit::EliminateCommonSubexpression(g); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); } @@ -357,13 +357,13 @@ TEST(Converters, UnpackVarUnbiasedKeepDimsLowersCorrectly) { auto g = std::make_shared(); torch::jit::parseIR(graph, g.get()); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); trtorch::core::lowering::passes::UnpackVar(g); torch::jit::EliminateCommonSubexpression(g); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); } @@ -383,13 +383,13 @@ TEST(Converters, UnpackStdLowersCorrectly) { auto g = std::make_shared(); torch::jit::parseIR(graph, g.get()); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); trtorch::core::lowering::passes::UnpackStd(g); trtorch::core::lowering::passes::UnpackVar(g); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); } @@ -409,13 +409,13 @@ TEST(Converters, UnpackStdKeepDimsLowersCorrectly) { auto g = std::make_shared(); torch::jit::parseIR(graph, g.get()); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); trtorch::core::lowering::passes::UnpackStd(g); trtorch::core::lowering::passes::UnpackVar(g); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); } @@ -435,14 +435,14 @@ TEST(Converters, UnpackStdUnbiasedLowersCorrectly) { auto g = std::make_shared(); torch::jit::parseIR(graph, g.get()); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); trtorch::core::lowering::passes::UnpackStd(g); trtorch::core::lowering::passes::UnpackVar(g); torch::jit::EliminateCommonSubexpression(g); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); } @@ -462,14 +462,14 @@ TEST(Converters, UnpackStdUnbiasedKeepDimsLowersCorrectly) { auto g = std::make_shared(); torch::jit::parseIR(graph, g.get()); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); trtorch::core::lowering::passes::UnpackStd(g); trtorch::core::lowering::passes::UnpackVar(g); torch::jit::EliminateCommonSubexpression(g); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); } @@ -488,13 +488,13 @@ TEST(Converters, UnpackVarUnbiasedNegAxisLowersCorrectly) { auto g = std::make_shared(); torch::jit::parseIR(graph, g.get()); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); in = at::clone(in); trtorch::core::lowering::passes::UnpackVar(g); torch::jit::EliminateCommonSubexpression(g); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {jit_in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); diff --git a/tests/core/conversion/converters/test_replication_pad.cpp b/tests/core/conversion/converters/test_replication_pad.cpp index 7c66bead0e..fbad882efb 100644 --- a/tests/core/conversion/converters/test_replication_pad.cpp +++ b/tests/core/conversion/converters/test_replication_pad.cpp @@ -17,10 +17,10 @@ TEST(Converters, ATenReplication_pad1dTensorConvertsCorrectly) { auto in1 = at::randint(1, 10, {1, 3, 4}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -38,10 +38,10 @@ TEST(Converters, ATenReplication_pad1dRightZeroTensorConvertsCorrectly) { auto in1 = at::randint(1, 10, {1, 3, 4}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -59,10 +59,10 @@ TEST(Converters, ATenReplication_pad1dTensorConvertsCorrectlyWithDynamic) { auto in1 = at::randint(1, 10, {1, 3, 4}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -80,10 +80,10 @@ TEST(Converters, ATenReplication_pad2dTensorConvertsCorrectly) { auto in1 = at::randint(1, 10, {1, 3, 4, 5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -101,10 +101,10 @@ TEST(Converters, ATenReplication_pad2dRightBottomZeroTensorConvertsCorrectly) { auto in1 = at::randint(1, 10, {1, 3, 4, 5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -122,10 +122,10 @@ TEST(Converters, ATenReplication_pad2dTensorConvertsCorrectlyWithDynamic) { auto in1 = at::randint(1, 10, {1, 3, 4, 5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -143,10 +143,10 @@ TEST(Converters, ATenReplication_pad3dTensorConvertsCorrectly) { auto in1 = at::randint(1, 10, {1, 3, 4, 5, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -164,10 +164,10 @@ TEST(Converters, ATenReplication_pad3dRightBottomBackZeroTensorConvertsCorrectly auto in1 = at::randint(1, 10, {1, 3, 4, 5, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -185,10 +185,10 @@ TEST(Converters, ATenReplication_pad3dTensorConvertsCorrectlyWithDynamic) { auto in1 = at::randint(1, 10, {1, 3, 4, 5, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); diff --git a/tests/core/conversion/converters/test_select.cpp b/tests/core/conversion/converters/test_select.cpp index 5977fbde53..77b417da57 100644 --- a/tests/core/conversion/converters/test_select.cpp +++ b/tests/core/conversion/converters/test_select.cpp @@ -20,11 +20,11 @@ TEST(Converters, ATenSelectIntConvertsCorrectly) { auto in = at::randint(1, 10, {4, 4, 4}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -47,11 +47,11 @@ TEST(Converters, ATenSelectIntDimIsOneConvertsCorrectly) { auto in = at::randint(1, 10, {4, 4, 4}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); // In order to check whether shape match that we don't do reshape. @@ -75,11 +75,11 @@ TEST(Converters, ATenSelectIntDimNegativeConvertsCorrectly) { auto in = at::randint(1, 10, {4, 4, 4}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -100,11 +100,11 @@ TEST(Converters, ATenSelectIntNegIndexConvertsCorrectly) { auto in = torch::tensor({2, 20, 768}).to(at::kFloat).to(at::kCUDA); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -128,11 +128,11 @@ TEST(Converters, ATenSelectIntTwiceConvertsCorrectly) { auto in = at::randint(1, 10, {4, 4, 4}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -155,11 +155,11 @@ TEST(Converters, ATenNarrowStartScalarConvertsCorrectly) { auto in = at::randint(1, 10, {3, 2, 2, 4}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape(jit_results[0].sizes()); @@ -183,7 +183,7 @@ TEST(Converters, ATenEmbeddingConvertsCorrectly) { auto jit_in = at::tensor({0, 1, 2}, options_pyt); auto embWeight = at::randn({10, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {embWeight}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {embWeight}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); // Run TensorRT @@ -216,7 +216,7 @@ TEST(Converters, ATenSliceConvertsCorrectly) { auto in = at::randint(1, 10, {1, 3, 5, 5}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); @@ -244,7 +244,7 @@ TEST(Converters, ATenSliceNegStartIndexConvertsCorrectly) { auto in = at::randint(1, 10, {6, 3}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); @@ -277,7 +277,7 @@ TEST(Converters, ATenSliceNegEndIndexConvertsCorrectly) { auto in = at::randint(1, 10, {6, 5, 3, 3}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); @@ -303,7 +303,7 @@ TEST(Converters, ATenSplitSizesInScriptingConvertsCorrectly) { auto in = at::randint(1, 10, {1, 3, 4, 4}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); @@ -331,7 +331,7 @@ TEST(Converters, ATenSplitSizesinTracingConvertsCorrectly) { auto in = at::randint(1, 10, {1, 3, 4, 4}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); @@ -358,7 +358,7 @@ TEST(Converters, ATenSplitFixedConvertsCorrectly) { auto in = at::randint(1, 10, {1, 3, 4, 4}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); @@ -386,7 +386,7 @@ TEST(Converters, ATenSplitFixedHasRemainderConvertsCorrectly) { auto in = at::randint(1, 10, {1, 5, 4, 4}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); @@ -415,7 +415,7 @@ TEST(Converters, ATenSplitAndAddConvertsCorrectly) { auto in = at::randint(1, 10, {1, 4, 4, 4}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); @@ -453,7 +453,7 @@ TEST(Converters, ATenMaskedFillZerosConvertsCorrectly) { auto in = at::zeros({1, 2, 3}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); diff --git a/tests/core/conversion/converters/test_shuffle.cpp b/tests/core/conversion/converters/test_shuffle.cpp index 0b99d4147e..603aa8a16a 100644 --- a/tests/core/conversion/converters/test_shuffle.cpp +++ b/tests/core/conversion/converters/test_shuffle.cpp @@ -17,11 +17,11 @@ TEST(Converters, ATenFlattenConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(0, 5, {2, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -41,11 +41,11 @@ TEST(Converters, ATenFlattenOtherDimsConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(0, 5, {2, 3, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -65,11 +65,11 @@ TEST(Converters, ATenReshapeConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(0, 5, {2, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -89,11 +89,11 @@ TEST(Converters, ATenViewConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(0, 5, {2, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -111,14 +111,14 @@ TEST(Converters, ATenPermuteConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(0, 5, {2, 3, 2, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); std::cout << "Running JIT" << std::endl; auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); std::cout << "Running TRT" << std::endl; in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -136,11 +136,11 @@ TEST(Converters, ATenPermute3DConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(0, 5, {2, 2, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -158,11 +158,11 @@ TEST(Converters, ATenPermute5DConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(0, 5, {2, 2, 1, 2, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -181,11 +181,11 @@ TEST(Converters, ATenFlattenConvertsCorrectlyWithDynamicInput) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(0, 5, {2, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {in}, false); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -204,11 +204,11 @@ TEST(Converters, ATenFlattenConvertsCorrectlyWithDynamicBatch) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(0, 5, {2, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngineDynamic(g, params, {in}, true); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -227,14 +227,14 @@ TEST(Converters, ATenTransposeConvertsCorrectly) { torch::jit::parseIR(graph, &*g); auto in = at::randint(0, 5, {2, 3, 4, 5, 6}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); std::cout << "Running JIT" << std::endl; auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); std::cout << "Running TRT" << std::endl; in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -251,14 +251,14 @@ TEST(Converters, ATenTConvertsCorrectly) { torch::jit::parseIR(graph, &*g); auto in = at::randint(0, 5, {3, 4}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); std::cout << "Running JIT" << std::endl; auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); std::cout << "Running TRT" << std::endl; in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -277,14 +277,14 @@ TEST(Converters, ATenTransposeNegativeConvertsCorrectly) { torch::jit::parseIR(graph, &*g); auto in = at::randint(0, 5, {2, 3, 4, 5, 6}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); std::cout << "Running JIT" << std::endl; auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); std::cout << "Running TRT" << std::endl; in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -302,14 +302,14 @@ TEST(Converters, ATenPixelShuffleConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(0, 5, {1, 9, 4, 5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); std::cout << "Running JIT" << std::endl; auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); std::cout << "Running TRT" << std::endl; in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); // auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -327,14 +327,14 @@ TEST(Converters, ATenPixelShuffle3DConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(0, 5, {9, 4, 5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); std::cout << "Running JIT" << std::endl; auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); std::cout << "Running TRT" << std::endl; in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); @@ -351,14 +351,14 @@ TEST(Converters, ATenPixelShuffle5DConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(0, 5, {2, 3, 9, 4, 5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); std::cout << "Running JIT" << std::endl; auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); std::cout << "Running TRT" << std::endl; in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); // auto trt = trt_results[0].reshape_as(jit_results[0]); diff --git a/tests/core/conversion/converters/test_softmax.cpp b/tests/core/conversion/converters/test_softmax.cpp index f8c68c0a4a..b7cc2b60e6 100644 --- a/tests/core/conversion/converters/test_softmax.cpp +++ b/tests/core/conversion/converters/test_softmax.cpp @@ -16,11 +16,11 @@ TEST(Converters, ATenSoftmax1DConvertsCorrectly) { torch::jit::parseIR(graph, g.get()); auto in = at::randint(0, 5, {5}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -40,11 +40,11 @@ TEST(Converters, ATenSoftmaxNDConvertsCorrectlySub3DIndex) { auto in = at::randint(0, 5, {1, 2, 2, 2, 2}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -65,11 +65,11 @@ TEST(Converters, ATenSoftmaxNDConvertsCorrectlyAbove3DIndex) { auto in = at::randint(0, 5, {1, 2, 2, 2, 2}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -91,11 +91,11 @@ TEST(Converters, ATenSoftmaxNDConvertsCorrectlyNegtiveOneIndex) { auto in = at::randint(0, 5, {1, 2, 2, 2, 2}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape_as(jit_results[0]); @@ -117,11 +117,11 @@ TEST(Converters, ATenSoftmaxNDConvertsCorrectlyNegtiveIndex) { auto in = at::randint(0, 5, {1, 2, 2, 2, 2}, {at::kCUDA}); auto jit_in = at::clone(in); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in}); auto trt_in = at::clone(in); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in}); auto trt = trt_results[0].reshape_as(jit_results[0]); diff --git a/tests/core/conversion/converters/test_squeeze.cpp b/tests/core/conversion/converters/test_squeeze.cpp index 7a142146aa..eaa4a90f78 100644 --- a/tests/core/conversion/converters/test_squeeze.cpp +++ b/tests/core/conversion/converters/test_squeeze.cpp @@ -16,10 +16,10 @@ TEST(Converters, ATenSqueezeConvertsCorrectly) { auto in = at::randint(1, 10, {2, 1, 3, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -43,13 +43,13 @@ TEST(Converters, ATenSqueezeDontNeedSqueezeConvertsCorrectly) { auto jit_in = at::clone(in); auto jit_in_add = at::clone(in_add); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {jit_in, jit_in_add}); auto trt_in = at::clone(jit_in); auto trt_in_add = at::clone(jit_in_add); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {trt_in, trt_in_add}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); diff --git a/tests/core/conversion/converters/test_stack.cpp b/tests/core/conversion/converters/test_stack.cpp index dddf1a0379..274e4a3069 100644 --- a/tests/core/conversion/converters/test_stack.cpp +++ b/tests/core/conversion/converters/test_stack.cpp @@ -19,10 +19,10 @@ TEST(Converters, ATenStackPureTensorConvertsCorrectly) { auto in1 = at::randint(1, 10, {4, 4, 4}, {at::kCUDA}); auto in2 = at::randint(1, 10, {4, 4, 4}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1, in2}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1, in2}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -43,10 +43,10 @@ TEST(Converters, ATenStackDiffTensorConvertsCorrectly) { auto in1 = at::randint(1, 10, {4, 4, 4}, {at::kCUDA}); auto in2 = at::randint(1, 10, {4, 4, 4}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {in2}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {in2}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {in2}); + params = trtorch::core::ir::get_static_params(g->inputs(), {in2}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); diff --git a/tests/core/conversion/converters/test_topk.cpp b/tests/core/conversion/converters/test_topk.cpp index 5156a04c89..54a5c8f12e 100644 --- a/tests/core/conversion/converters/test_topk.cpp +++ b/tests/core/conversion/converters/test_topk.cpp @@ -19,10 +19,10 @@ TEST(Converters, ATenTopKConvertsCorrectly) { auto in = at::rand({10, 10, 100}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); diff --git a/tests/core/conversion/converters/test_unary.cpp b/tests/core/conversion/converters/test_unary.cpp index 2910f3ab87..1cc8f13def 100644 --- a/tests/core/conversion/converters/test_unary.cpp +++ b/tests/core/conversion/converters/test_unary.cpp @@ -25,11 +25,11 @@ std::string gen_test_graph(const std::string& unary) { if (strcmp(#name, "Acosh") == 0) \ offset += 1; /*input larger than 1 for acosh*/ \ auto in = at::empty({10}, {at::kCUDA}).uniform_(0 + offset, 0.5 + offset); \ - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); \ + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); \ auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); \ \ in = at::clone(in); \ - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); \ + params = trtorch::core::ir::get_static_params(g->inputs(), {}); \ auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); \ \ ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0], 2e-6)); \ diff --git a/tests/core/conversion/converters/test_unsqueeze.cpp b/tests/core/conversion/converters/test_unsqueeze.cpp index b1142dc2fc..9dea1674c6 100644 --- a/tests/core/conversion/converters/test_unsqueeze.cpp +++ b/tests/core/conversion/converters/test_unsqueeze.cpp @@ -16,10 +16,10 @@ TEST(Converters, ATenUnsqueezeConvertsCorrectly) { auto in = at::randint(1, 10, {2, 3, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -37,10 +37,10 @@ TEST(Converters, ATenUnsqueezeNegativeDimConvertsCorrectly) { auto in = at::randint(1, 10, {2, 3, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); diff --git a/tests/core/conversion/evaluators/test_aten_evaluators.cpp b/tests/core/conversion/evaluators/test_aten_evaluators.cpp index a49b11807d..5bc504362a 100644 --- a/tests/core/conversion/evaluators/test_aten_evaluators.cpp +++ b/tests/core/conversion/evaluators/test_aten_evaluators.cpp @@ -260,10 +260,10 @@ TEST(Evaluators, ATenSizeNegativeConvertsCorrectly) { auto in = at::randint(1, 10, {3, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -316,10 +316,10 @@ TEST(Evaluators, ATenAppendWithITensorEvaluatesCorrectly) { auto in0 = at::randint(1, 10, {3, 3}, {at::kCUDA}); auto in1 = at::randint(1, 10, {3, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in0, in1}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in0, in1}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -346,10 +346,10 @@ TEST(Evaluators, ATenAppendWithTensorEvaluatesCorrectly) { auto in0 = at::randint(1, 10, {6, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in0}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in0}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); @@ -373,10 +373,10 @@ TEST(Evaluators, ATenAppendWithITensorAndTensorEvaluatesCorrectly) { auto in0 = at::randint(1, 10, {3, 3}, {at::kCUDA}); - auto params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + auto params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto jit_results = trtorch::tests::util::RunGraph(g, params, {in0}); - params = trtorch::core::conversion::get_named_params(g->inputs(), {}); + params = trtorch::core::ir::get_static_params(g->inputs(), {}); auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in0}); ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0]), 2e-6)); diff --git a/tests/core/lowering/test_module_fallback_passes.cpp b/tests/core/lowering/test_module_fallback_passes.cpp index 6f4b4209e2..d553bf8507 100644 --- a/tests/core/lowering/test_module_fallback_passes.cpp +++ b/tests/core/lowering/test_module_fallback_passes.cpp @@ -96,6 +96,8 @@ TEST(Lowering, LowerAndPartitionSimpleModuleFallbackCorrectly) { trt_inputs_ivalues.push_back(in.clone()); } + auto g = mod.get_method("forward").graph(); + std::vector input_ranges{trtorch::core::ir::Input({1, 1, 16, 16})}; trtorch::core::CompileSpec cfg(input_ranges); cfg.partition_info.enabled = true; @@ -104,8 +106,8 @@ TEST(Lowering, LowerAndPartitionSimpleModuleFallbackCorrectly) { auto jit_results = mod.forward(jit_inputs_ivalues).toTensor(); auto trt_mod = trtorch::core::CompileGraph(mod, cfg); - auto g = trt_mod.get_method("forward").graph(); - auto nodes = g->block()->nodes(); + auto trt_g = trt_mod.get_method("forward").graph(); + auto nodes = trt_g->block()->nodes(); std::size_t curr_node = 0; for (const auto n : nodes) { if (curr_node == 5) { diff --git a/tests/core/lowering/test_unpack_hardswish.cpp b/tests/core/lowering/test_unpack_hardswish.cpp index d60d3d0ae9..7f2e629e07 100644 --- a/tests/core/lowering/test_unpack_hardswish.cpp +++ b/tests/core/lowering/test_unpack_hardswish.cpp @@ -29,7 +29,7 @@ TEST(LoweringPasses, UnpackHardSwish) { torch::jit::parseIR(source_graph, &*sg); auto in = at::rand({10, 100}, {at::kCUDA}); - auto sg_params = trtorch::core::conversion::get_named_params(sg->inputs(), {}); + auto sg_params = trtorch::core::ir::get_static_params(sg->inputs(), {}); auto sg_results = trtorch::tests::util::RunGraph(sg, sg_params, {in}); trtorch::core::lowering::passes::UnpackHardSwish(sg); @@ -40,7 +40,7 @@ TEST(LoweringPasses, UnpackHardSwish) { ASSERT_TRUE(!torch::jit::findPatternMatches(*tg, *sg).empty()); in = at::clone(in); - auto tg_params = trtorch::core::conversion::get_named_params(tg->inputs(), {}); + auto tg_params = trtorch::core::ir::get_static_params(tg->inputs(), {}); auto tg_results = trtorch::tests::util::RunGraph(tg, tg_params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(sg_results[0], tg_results[0], 2e-6)); @@ -69,7 +69,7 @@ TEST(LoweringPasses, UnpackHardInplaceSwish) { torch::jit::parseIR(source_graph, &*sg); auto in = at::rand({10, 100}, {at::kCUDA}); - auto sg_params = trtorch::core::conversion::get_named_params(sg->inputs(), {}); + auto sg_params = trtorch::core::ir::get_static_params(sg->inputs(), {}); auto sg_results = trtorch::tests::util::RunGraph(sg, sg_params, {in}); trtorch::core::lowering::passes::UnpackHardSwish(sg); @@ -80,7 +80,7 @@ TEST(LoweringPasses, UnpackHardInplaceSwish) { ASSERT_TRUE(!torch::jit::findPatternMatches(*tg, *sg).empty()); in = at::clone(in); - auto tg_params = trtorch::core::conversion::get_named_params(tg->inputs(), {}); + auto tg_params = trtorch::core::ir::get_static_params(tg->inputs(), {}); auto tg_results = trtorch::tests::util::RunGraph(tg, tg_params, {in}); ASSERT_TRUE(trtorch::tests::util::almostEqual(sg_results[0], tg_results[0], 2e-6)); diff --git a/tests/core/partitioning/test_conditionals.cpp b/tests/core/partitioning/test_conditionals.cpp index 27b3fc2c10..dce8c52604 100644 --- a/tests/core/partitioning/test_conditionals.cpp +++ b/tests/core/partitioning/test_conditionals.cpp @@ -32,12 +32,13 @@ TEST(Partitioning, FallbackOnConditionalsCorrectly) { } std::vector inputs{trtorch::core::ir::Input({3, 3, 16, 16})}; + auto g = mod.get_method("forward").graph(); trtorch::core::CompileSpec cfg(inputs); cfg.partition_info.enabled = true; torch::jit::script::Module new_mod = trtorch::core::CompileGraph(mod, cfg); - auto g = new_mod.get_method("forward").graph(); + auto new_g = new_mod.get_method("forward").graph(); - auto conditional_engines_count = count_trt_engines_in_conditionals(g); + auto conditional_engines_count = count_trt_engines_in_conditionals(new_g); ASSERT_TRUE(conditional_engines_count == 2); } diff --git a/tests/core/partitioning/test_fallback_graph_output.cpp b/tests/core/partitioning/test_fallback_graph_output.cpp index de382947ff..9cb03d8305 100644 --- a/tests/core/partitioning/test_fallback_graph_output.cpp +++ b/tests/core/partitioning/test_fallback_graph_output.cpp @@ -24,6 +24,7 @@ TEST(Partitioning, ComputeResNet50FallbackGraphCorrectly) { } std::vector input_ranges{trtorch::core::ir::Input({1, 3, 224, 224})}; + trtorch::core::CompileSpec cfg(input_ranges); cfg.partition_info.enabled = true; cfg.partition_info.forced_fallback_operators.push_back("aten::add"); @@ -53,6 +54,7 @@ TEST(Partitioning, ComputeMobileNetFallbackGraphCorrectly) { } std::vector input_ranges{trtorch::core::ir::Input({1, 3, 224, 224})}; + auto g = mod.get_method("forward").graph(); trtorch::core::CompileSpec cfg(input_ranges); cfg.partition_info.enabled = true; cfg.partition_info.forced_fallback_operators.push_back("aten::hardtanh"); @@ -83,7 +85,11 @@ TEST(Partitioning, ComputeResNet50HalfFallbackGraphCorrectly) { trt_inputs_ivalues.push_back(in.clone()); } - std::vector input_ranges{trtorch::core::ir::Input({1, 3, 224, 224})}; + auto in_shape = trtorch::core::ir::Input({1, 3, 224, 224}); + in_shape.dtype = nvinfer1::DataType::kHALF; + + std::vector input_ranges({in_shape}); + auto g = mod.get_method("forward").graph(); trtorch::core::CompileSpec cfg(input_ranges); cfg.partition_info.enabled = true; cfg.partition_info.forced_fallback_operators.push_back("aten::add"); @@ -91,5 +97,6 @@ TEST(Partitioning, ComputeResNet50HalfFallbackGraphCorrectly) { auto jit_results = mod.forward(jit_inputs_ivalues).toTensor(); auto trt_mod = trtorch::core::CompileGraph(mod, cfg); auto trt_results = trt_mod.forward(trt_inputs_ivalues).toTensor(); - ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results, trt_results, 2e-6)); + // Lower threshold because FP16 + ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results, trt_results, 2e-1)); } \ No newline at end of file diff --git a/tests/core/partitioning/test_segmentation.cpp b/tests/core/partitioning/test_segmentation.cpp index e789a2b524..b713b7470f 100644 --- a/tests/core/partitioning/test_segmentation.cpp +++ b/tests/core/partitioning/test_segmentation.cpp @@ -16,7 +16,8 @@ bool checkSegmentedBlockNumber( cnt++; } } - std::cout << "Found count of " << cnt << " " << target << " blocks (looking for " << target_count << " blocks)" << std::endl; + std::cout << "Found count of " << cnt << " " << target << " blocks (looking for " << target_count << " blocks)" + << std::endl; if (target_count != cnt) { std::cout << segmented_blocks << std::endl; diff --git a/tests/core/partitioning/test_shape_analysis.cpp b/tests/core/partitioning/test_shape_analysis.cpp index 60c5d350eb..acb643e6bd 100644 --- a/tests/core/partitioning/test_shape_analysis.cpp +++ b/tests/core/partitioning/test_shape_analysis.cpp @@ -11,7 +11,7 @@ bool checkSegmentedBlockInputShape( if (segmented_blocks.size() != in_shape.size()) return false; for (size_t i = 0; i < segmented_blocks.size(); ++i) { - auto cur_block_in_shapes = segmented_blocks[i].in_shape(); + auto cur_block_in_shapes = segmented_blocks[i].in_shapes(); if (cur_block_in_shapes.size() != in_shape[i].size()) return false; for (size_t j = 0; j < cur_block_in_shapes.size(); ++j) { @@ -59,11 +59,13 @@ TEST(Partitioning, InferSequentialModelSegmentedBlockShapeCorrectly) { inputs.push_back(trtorch::core::ir::Input({8, 16, 3, 3})); inputs.push_back(trtorch::core::ir::Input({8})); - std::unordered_map inputs_map; + std::unordered_map inputs_map; + std::unordered_map> input_types; for (size_t i = 0; i < g->inputs().size(); ++i) { inputs_map.insert({g->inputs()[i], inputs[i]}); + input_types.insert({g->inputs()[i], {at::kFloat}}); } - auto input_ivalues_map = trtorch::core::partitioning::generateRandomInputs(inputs_map, at::kFloat); + auto input_ivalues_map = trtorch::core::partitioning::generateRandomInputs(inputs_map, input_types); std::vector segmented_blocks = trtorch::core::partitioning::Partition(g->block(), input_ivalues_map, partition_info); @@ -107,11 +109,13 @@ TEST(Partitioning, InferBranchModelSegmentedBlockShapeCorrectly) { inputs.push_back(trtorch::core::ir::Input({16, 32, 3, 3})); inputs.push_back(trtorch::core::ir::Input({16})); - std::unordered_map inputs_map; + std::unordered_map inputs_map; + std::unordered_map> input_types; for (size_t i = 0; i < g->inputs().size(); ++i) { inputs_map.insert({g->inputs()[i], inputs[i]}); + input_types.insert({g->inputs()[i], {at::kFloat}}); } - auto input_ivalues_map = trtorch::core::partitioning::generateRandomInputs(inputs_map, at::kFloat); + auto input_ivalues_map = trtorch::core::partitioning::generateRandomInputs(inputs_map, input_types); std::vector segmented_blocks = trtorch::core::partitioning::Partition(g->block(), input_ivalues_map, partition_info); diff --git a/tests/core/partitioning/test_stitched_graph.cpp b/tests/core/partitioning/test_stitched_graph.cpp index 1b3b2717e5..ad2834f530 100644 --- a/tests/core/partitioning/test_stitched_graph.cpp +++ b/tests/core/partitioning/test_stitched_graph.cpp @@ -63,10 +63,6 @@ TEST(Partitioning, StitchSequentialModelSegmentedBlockCorrectly) { } g->registerOutput(tensor_to_constant[parsed_g->outputs()[0]]); - std::vector inputs; - inputs.push_back(trtorch::core::ir::Input({3, 3, 16, 16})); - trtorch::core::CompileSpec cfg(inputs); - cfg.partition_info.enabled = true; torch::jit::script::Module mod(c10::QualifiedName("module")); auto self = g->insertInput(0, "self_1"); @@ -76,6 +72,10 @@ TEST(Partitioning, StitchSequentialModelSegmentedBlockCorrectly) { mod.type()->addMethod(cur_method); cur_method->setSchema(schema); + std::vector inputs; + inputs.push_back(trtorch::core::ir::Input({3, 3, 16, 16})); + trtorch::core::CompileSpec cfg(inputs); + cfg.partition_info.enabled = true; torch::jit::script::Module new_mod = trtorch::core::CompileGraph(mod, cfg); auto fallback_g = new_mod.get_method("forward").graph(); ASSERT_TRUE(checkAllInputsExistInStitchedGraph(fallback_g)); @@ -121,10 +121,6 @@ TEST(Partitioning, StitchBranchModelSegmentedBlockCorrectly) { } g->registerOutput(tensor_to_constant[parsed_g->outputs()[0]]); - std::vector inputs; - inputs.push_back(trtorch::core::ir::Input({3, 3, 16, 16})); - trtorch::core::CompileSpec cfg(inputs); - cfg.partition_info.enabled = true; torch::jit::script::Module mod(c10::QualifiedName("module")); auto self = g->insertInput(0, "self_1"); @@ -134,6 +130,10 @@ TEST(Partitioning, StitchBranchModelSegmentedBlockCorrectly) { mod.type()->addMethod(cur_method); cur_method->setSchema(schema); + std::vector inputs; + inputs.push_back(trtorch::core::ir::Input({3, 3, 16, 16})); + trtorch::core::CompileSpec cfg(inputs); + cfg.partition_info.enabled = true; torch::jit::script::Module new_mod = trtorch::core::CompileGraph(mod, cfg); auto fallback_g = new_mod.get_method("forward").graph(); ASSERT_TRUE(checkAllInputsExistInStitchedGraph(fallback_g)); diff --git a/tests/util/run_graph.cpp b/tests/util/run_graph.cpp index 916dd98ca7..529c5311c7 100644 --- a/tests/util/run_graph.cpp +++ b/tests/util/run_graph.cpp @@ -11,7 +11,7 @@ torch::jit::Stack CreateStack(std::vector&& list) { std::vector RunGraph( std::shared_ptr& g, - core::conversion::GraphParams& params, + core::ir::StaticParams& params, std::vector inputs) { LOG_DEBUG("Running JIT version"); std::vector inputs_; diff --git a/tests/util/run_graph_engine.cpp b/tests/util/run_graph_engine.cpp index d8a8058240..faefc2dd19 100644 --- a/tests/util/run_graph_engine.cpp +++ b/tests/util/run_graph_engine.cpp @@ -60,14 +60,28 @@ std::vector RunEngine(std::string& eng, std::vector inpu return outputs; } +std::vector get_var_inputs( + c10::ArrayRef ins, + core::ir::StaticParams& static_ins) { + std::vector var_ins; + for (auto in : ins) { + if (static_ins.find(in) == static_ins.end()) { + var_ins.push_back(in); + } + } + return var_ins; +} + std::vector RunGraphEngine( std::shared_ptr& g, - core::conversion::GraphParams& named_params, + core::ir::StaticParams& named_params, std::vector inputs, nvinfer1::DataType op_precision = nvinfer1::DataType::kFLOAT) { LOG_DEBUG("Running TRT version"); - auto in = toInputs(inputs); - auto info = core::conversion::ConversionInfo(in); + auto var_ins = get_var_inputs(g->inputs(), named_params); + auto in = core::ir::pair_input_vals_with_specs(var_ins, toInputs(inputs)); + auto info = core::conversion::ConversionInfo(); + info.inputs = std::move(in); info.engine_settings.workspace_size = 1 << 20; info.engine_settings.enabled_precisions.insert(op_precision); std::string eng = core::conversion::ConvertBlockToEngine(g->block(), info, named_params); @@ -76,12 +90,14 @@ std::vector RunGraphEngine( std::vector RunGraphEngineDynamic( std::shared_ptr& g, - core::conversion::GraphParams& named_params, + core::ir::StaticParams& named_params, std::vector inputs, bool dynamic_batch) { LOG_DEBUG("Running TRT version"); - auto in = toInputsDynamic(inputs, dynamic_batch); - auto info = core::conversion::ConversionInfo(in); + auto var_ins = get_var_inputs(g->inputs(), named_params); + auto in = core::ir::pair_input_vals_with_specs(var_ins, toInputs(inputs)); + auto info = core::conversion::ConversionInfo(); + info.inputs = std::move(in); info.engine_settings.workspace_size = 1 << 20; std::string eng = core::conversion::ConvertBlockToEngine(g->block(), info, named_params); return RunEngine(eng, inputs); diff --git a/tests/util/util.h b/tests/util/util.h index e8b4765c0d..7eb721e6b8 100644 --- a/tests/util/util.h +++ b/tests/util/util.h @@ -4,7 +4,7 @@ #include #include "ATen/Tensor.h" -#include "core/conversion/conversion.h" +#include "core/ir/ir.h" #include "core/util/prelude.h" namespace trtorch { @@ -20,14 +20,14 @@ std::vector RunEngine(std::string& eng, std::vector inpu // Runs an arbitrary JIT graph and returns results std::vector RunGraph( std::shared_ptr& g, - core::conversion::GraphParams& named_params, + core::ir::StaticParams& named_params, std::vector inputs); // Runs an arbitrary JIT graph by converting it to TensorRT and running // inference and returns results std::vector RunGraphEngine( std::shared_ptr& g, - core::conversion::GraphParams& named_params, + core::ir::StaticParams& named_params, std::vector inputs, nvinfer1::DataType dtype = nvinfer1::DataType::kFLOAT); @@ -35,7 +35,7 @@ std::vector RunGraphEngine( // TensorRT and running inference and returns results std::vector RunGraphEngineDynamic( std::shared_ptr& g, - core::conversion::GraphParams& named_params, + core::ir::StaticParams& named_params, std::vector inputs, bool dynamic_batch = false);