mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
Enable provider unit tests for TensorRT (#802)
* Update provider_test_utils.cc * Update tensorrt_execution_provider.h * Update tensorrt_execution_provider.cc * Update gemm_test.cc * Update softmax_test.cc * Update logsoftmax_test.cc * Update matmul_test.cc * Update batch_norm_op_test.cc * Update conv_op_test.cc * Update batch_norm_op_test.cc * Update softmax_test.cc * Update conv_transpose_op_test.cc * Update instance_norm_op_test.cc * Update flatten_op_test.cc * Update loop_test.cc * Disable failed tests for TensorRT * Disable unsupported tests for TensorRT * Disable unsupported tests for TensorRT * Disable unsupported tests for TensorRT * Disable unsupported tests for TensorRT * Update matmul_test.cc * Update logsoftmax_test.cc * Update topk_op_test.cc * disable unsupported tests for TensorRT * resolve conflicts * Update identity_op_test.cc * Update activation_op_test.cc * make max batch size configurable and simplify the code for disabling unsupported tests * make max batch size configurable at runtime * update tensorrt ci pipline * move max batch size to private * Update tensorrt_execution_provider.cc * Update tensorrt_execution_provider.h * Update tensorrt_execution_provider.cc * add comments on the test changes * Update tensorrt_execution_provider.h * Update tensorrt_execution_provider.cc * Update build.py
This commit is contained in:
parent
ff253631b5
commit
f2694ab526
35 changed files with 375 additions and 276 deletions
|
|
@ -114,7 +114,7 @@ if (onnxruntime_USE_TENSORRT)
|
|||
set(CUDA_INCLUDE_DIRS ${onnxruntime_CUDA_HOME}/include)
|
||||
set(TENSORRT_ROOT ${onnxruntime_TENSORRT_HOME})
|
||||
include_directories(${ONNXRUNTIME_ROOT}/../cmake/external/onnx)
|
||||
set(OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
set(OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
if (WIN32)
|
||||
set(OLD_CMAKE_CUDA_FLAGS ${CMAKE_CUDA_FLAGS})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996 /wd4244 /wd4267 /wd4099 /wd4551 /wd4505 /wd4515 /wd4706 /wd4456")
|
||||
|
|
@ -127,10 +127,10 @@ if (onnxruntime_USE_TENSORRT)
|
|||
endif()
|
||||
if ( CMAKE_COMPILER_IS_GNUCC )
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-missing-field-initializers")
|
||||
endif()
|
||||
endif()
|
||||
set(CXX_VERSION_DEFINED TRUE)
|
||||
add_subdirectory(${ONNXRUNTIME_ROOT}/../cmake/external/onnx-tensorrt)
|
||||
set(CMAKE_CXX_FLAGS ${OLD_CMAKE_CXX_FLAGS})
|
||||
add_subdirectory(${ONNXRUNTIME_ROOT}/../cmake/external/onnx-tensorrt)
|
||||
set(CMAKE_CXX_FLAGS ${OLD_CMAKE_CXX_FLAGS})
|
||||
if (WIN32)
|
||||
set(CMAKE_CUDA_FLAGS ${OLD_CMAKE_CUDA_FLAGS})
|
||||
unset(PROTOBUF_LIBRARY)
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ TensorrtExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph,
|
|||
const std::vector<NodeIndex>& node_index = graph.GetNodesInTopologicalOrder();
|
||||
for (const auto& node : graph.Nodes()) {
|
||||
graph_build.AddNode(node);
|
||||
}
|
||||
}
|
||||
ORT_ENFORCE(graph_build.Resolve().IsOK());
|
||||
ONNX_NAMESPACE::ModelProto model_proto = model.ToProto();
|
||||
model_proto.set_ir_version(ONNX_NAMESPACE::Version::IR_VERSION);
|
||||
|
|
@ -80,7 +80,7 @@ TensorrtExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph,
|
|||
node_set.reserve(group.size());
|
||||
for (const auto& index : group) {
|
||||
node_set.insert(node_index[index]);
|
||||
}
|
||||
}
|
||||
std::unique_ptr<IndexedSubGraph> sub_graph = std::make_unique<IndexedSubGraph>();
|
||||
// Find inputs and outputs of the subgraph
|
||||
std::unordered_map<const NodeArg *, int> fused_inputs, fused_outputs, fused_outputs_to_add;
|
||||
|
|
@ -279,14 +279,27 @@ common::Status TensorrtExecutionProvider::Compile(const std::vector<onnxruntime:
|
|||
// Create TensorRT engine
|
||||
string string_buf;
|
||||
model_proto.SerializeToString(&string_buf);
|
||||
|
||||
|
||||
TensorrtLogger trt_logger(nvinfer1::ILogger::Severity::kWARNING);
|
||||
auto trt_builder = unique_pointer<nvinfer1::IBuilder>(nvinfer1::createInferBuilder(trt_logger));
|
||||
auto trt_network = unique_pointer<nvinfer1::INetworkDefinition>(trt_builder->createNetwork());
|
||||
auto trt_parser = unique_pointer<nvonnxparser::IParser>(nvonnxparser::createParser(*trt_network, trt_logger));
|
||||
trt_parser->parse(string_buf.data(), string_buf.size());
|
||||
trt_builder->setMaxBatchSize(kMaxBatchSize);
|
||||
trt_builder->setMaxWorkspaceSize(kMaxWorkSpaceSize);
|
||||
|
||||
const char* batch_env = getenv("ORT_TENSORRT_MAX_BATCH_SIZE");
|
||||
if (batch_env) {
|
||||
const int max_batch_size = atoi(batch_env);
|
||||
SetMaxBatchSize(max_batch_size);
|
||||
}
|
||||
|
||||
const char* workspace_env = getenv("ORT_TENSORRT_MAX_WORKSPACE_SIZE");
|
||||
if (workspace_env) {
|
||||
const size_t max_workspace_size = atoi(workspace_env);
|
||||
SetMaxWorkspaceSize(max_workspace_size);
|
||||
}
|
||||
|
||||
trt_builder->setMaxBatchSize(max_batch_size_);
|
||||
trt_builder->setMaxWorkspaceSize(max_workspace_size_);
|
||||
auto trt_engine = unique_pointer<nvinfer1::ICudaEngine>(trt_builder->buildCudaEngine(*trt_network.get()));
|
||||
ORT_ENFORCE(trt_engine != nullptr);
|
||||
|
||||
|
|
@ -333,6 +346,11 @@ common::Status TensorrtExecutionProvider::Compile(const std::vector<onnxruntime:
|
|||
dim_size *= dimensions.d[j];
|
||||
}
|
||||
output_dim_sizes[bindingIndex] = dim_size;
|
||||
|
||||
const auto& tensor_shape = graph_output[i].type().tensor_type().shape();
|
||||
if (tensor_shape.dim_size() == 1 && output_shapes[bindingIndex].back() == 1) {
|
||||
output_shapes[bindingIndex].pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
ORT_ENFORCE(trt_engine->getNbBindings() == (num_inputs + num_outputs));
|
||||
|
|
|
|||
|
|
@ -11,9 +11,6 @@
|
|||
|
||||
namespace onnxruntime {
|
||||
|
||||
static const int kMaxBatchSize = 1;
|
||||
static const int kMaxWorkSpaceSize = 1 << 30;
|
||||
|
||||
class TensorrtLogger : public nvinfer1::ILogger {
|
||||
nvinfer1::ILogger::Severity verbosity_;
|
||||
public:
|
||||
|
|
@ -76,7 +73,18 @@ class TensorrtExecutionProvider : public IExecutionProvider {
|
|||
|
||||
std::shared_ptr<KernelRegistry> GetKernelRegistry() const override;
|
||||
|
||||
void SetMaxBatchSize(const int batch_size) {
|
||||
max_batch_size_ = batch_size;
|
||||
}
|
||||
|
||||
void SetMaxWorkspaceSize(const size_t workspace_size) {
|
||||
max_workspace_size_ = workspace_size;
|
||||
}
|
||||
|
||||
private:
|
||||
int max_batch_size_ = 1;
|
||||
size_t max_workspace_size_ = 1 << 30; // 1GB
|
||||
|
||||
struct InferDeleter {
|
||||
template <typename T>
|
||||
void operator()(T* obj) const {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ namespace test {
|
|||
void TestUnaryElementwiseOp(const char* szOp, std::vector<float>& input_vals,
|
||||
std::function<float(float)> expected_func,
|
||||
const std::unordered_map<std::string, float> attribs = {},
|
||||
bool is_tensorrt_supported = true,
|
||||
int opset_version = 7) {
|
||||
OpTester test(szOp, opset_version);
|
||||
|
||||
|
|
@ -25,7 +26,13 @@ void TestUnaryElementwiseOp(const char* szOp, std::vector<float>& input_vals,
|
|||
|
||||
test.AddInput<float>("X", dims, input_vals);
|
||||
test.AddOutput<float>("Y", dims, expected_vals);
|
||||
test.Run();
|
||||
|
||||
// Disable TensorRT on unsupported tests
|
||||
std::unordered_set<std::string> excluded_providers;
|
||||
if (!is_tensorrt_supported) {
|
||||
excluded_providers.insert(kTensorrtExecutionProvider);
|
||||
}
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", excluded_providers);
|
||||
}
|
||||
|
||||
std::vector<float> input_vals = {
|
||||
|
|
@ -93,7 +100,7 @@ TEST(ActivationOpTest, ThresholdedRelu) {
|
|||
TestUnaryElementwiseOp("ThresholdedRelu",
|
||||
input_vals,
|
||||
[alpha](float x) { return (x >= alpha) ? x : 0; },
|
||||
{{"alpha", alpha}}, 10);
|
||||
{{"alpha", alpha}}, true, 10);
|
||||
}
|
||||
|
||||
TEST(ActivationOpTest, Selu) {
|
||||
|
|
@ -180,7 +187,7 @@ TEST(ActivationOpTest, ThresholdedRelu_version_1_to_9) {
|
|||
TestUnaryElementwiseOp("ThresholdedRelu",
|
||||
input_vals,
|
||||
[alpha](float x) { return (x >= alpha) ? x : 0; },
|
||||
{{"alpha", alpha}}, 1);
|
||||
{{"alpha", alpha}}, true, 1);
|
||||
}
|
||||
|
||||
TEST(ActivationOpTest, ScaledTanh) {
|
||||
|
|
@ -218,7 +225,7 @@ TEST(ActivationOpTest, Softplus) {
|
|||
return x + logf(expf(-x) + 1);
|
||||
else
|
||||
return logf(expf(x) + 1);
|
||||
});
|
||||
}, {}, false);
|
||||
}
|
||||
|
||||
TEST(ActivationOpTest, Softsign) {
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ static const ONNX_NAMESPACE::GraphProto CreateSubgraph(bool then_branch, const R
|
|||
|
||||
/*
|
||||
Main graph
|
||||
|
||||
split_input if_cond if_graph_input_0,
|
||||
|
||||
split_input if_cond if_graph_input_0,
|
||||
| | |
|
||||
[Split] | [Identity]
|
||||
| | |
|
||||
| | if_input_0
|
||||
| | |
|
||||
| | if_input_0
|
||||
| split_out_0 | |
|
||||
------------------[If]-------------- (see below for then/else subgraphs in If node)
|
||||
split_out_1 |
|
||||
|
|
@ -108,17 +108,17 @@ class IfOpTester : public OpTester {
|
|||
THEN branch
|
||||
split_out_0 if_input_0 [1]
|
||||
\ |
|
||||
[1] \ |
|
||||
[1] \ |
|
||||
\------[Add]
|
||||
|
|
||||
|
|
||||
add_out_0 [2]
|
||||
|
||||
ELSE branch
|
||||
split_out_1 if_input_0 [1]
|
||||
split_out_1 if_input_0 [1]
|
||||
\ |
|
||||
[10] \ |
|
||||
[10] \ |
|
||||
\------[Add]
|
||||
|
|
||||
|
|
||||
add_out_1 [11]
|
||||
*/
|
||||
|
||||
|
|
@ -183,6 +183,7 @@ static const ONNX_NAMESPACE::GraphProto CreateSubgraph(bool then_branch, const R
|
|||
|
||||
void RunTest(bool condition_value,
|
||||
RunOptions options,
|
||||
bool is_tensorrt_supported = true,
|
||||
OpTester::ExpectResult expect_result = OpTester::ExpectResult::kExpectSuccess,
|
||||
const std::string& failure_message = "") {
|
||||
IfOpTester test{options};
|
||||
|
|
@ -209,6 +210,11 @@ void RunTest(bool condition_value,
|
|||
test.AddOutput<float>("if_out_0", output_shape, {11.f});
|
||||
}
|
||||
|
||||
std::unordered_set<std::string> excluded_providers;
|
||||
// Disable TensorRT on SymbolicShape or NoShape tests
|
||||
if (!is_tensorrt_supported) {
|
||||
excluded_providers.insert(kTensorrtExecutionProvider);
|
||||
}
|
||||
if (options.mixed_execution_providers) {
|
||||
// we want the CUDA provider to be first, and the CPU provider second. all except the Scannode should run on
|
||||
// CUDA given that, which creates the scenario where we need to copy to/from CPU to execute the Scan node correctly.
|
||||
|
|
@ -216,9 +222,9 @@ void RunTest(bool condition_value,
|
|||
execution_providers.push_back(DefaultCudaExecutionProvider());
|
||||
execution_providers.push_back(DefaultCpuExecutionProvider());
|
||||
|
||||
test.Run(expect_result, failure_message, {}, nullptr, &execution_providers);
|
||||
test.Run(expect_result, failure_message, excluded_providers, nullptr, &execution_providers);
|
||||
} else {
|
||||
test.Run(expect_result, failure_message);
|
||||
test.Run(expect_result, failure_message, excluded_providers);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -227,7 +233,7 @@ TEST(If, ShapeInMainGraph_NoShapeInSubgraph_True) {
|
|||
options.include_dim_values_in_main_graph = true;
|
||||
options.include_dim_values_in_subgraph = false;
|
||||
|
||||
RunTest(true, options);
|
||||
RunTest(true, options, false);
|
||||
}
|
||||
|
||||
TEST(If, ShapeInMainGraph_NoShapeInSubgraph_False) {
|
||||
|
|
@ -235,7 +241,7 @@ TEST(If, ShapeInMainGraph_NoShapeInSubgraph_False) {
|
|||
options.include_dim_values_in_main_graph = true;
|
||||
options.include_dim_values_in_subgraph = false;
|
||||
|
||||
RunTest(false, options);
|
||||
RunTest(false, options, false);
|
||||
}
|
||||
|
||||
TEST(If, NoShapeInMainGraph_ShapeInSubgraph_True) {
|
||||
|
|
@ -243,7 +249,7 @@ TEST(If, NoShapeInMainGraph_ShapeInSubgraph_True) {
|
|||
options.include_dim_values_in_main_graph = false;
|
||||
options.include_dim_values_in_subgraph = true;
|
||||
|
||||
RunTest(true, options);
|
||||
RunTest(true, options, false);
|
||||
}
|
||||
|
||||
TEST(If, NoShapeInMainGraph_ShapeInSubgraph_False) {
|
||||
|
|
@ -251,7 +257,7 @@ TEST(If, NoShapeInMainGraph_ShapeInSubgraph_False) {
|
|||
options.include_dim_values_in_main_graph = false;
|
||||
options.include_dim_values_in_subgraph = true;
|
||||
|
||||
RunTest(false, options);
|
||||
RunTest(false, options, false);
|
||||
}
|
||||
|
||||
#ifdef USE_CUDA
|
||||
|
|
@ -268,7 +274,7 @@ TEST(If, SymbolicShapeInMainGraph_NoShapeInSubgraph_True) {
|
|||
options.symbolic_dim_value_in_main_graph = 0;
|
||||
options.include_dim_values_in_subgraph = false;
|
||||
|
||||
RunTest(true, options);
|
||||
RunTest(true, options, false);
|
||||
}
|
||||
|
||||
TEST(If, SymbolicShapeInMainGraph_NoShapeInSubgraph_False) {
|
||||
|
|
@ -277,7 +283,7 @@ TEST(If, SymbolicShapeInMainGraph_NoShapeInSubgraph_False) {
|
|||
options.symbolic_dim_value_in_main_graph = 0;
|
||||
options.include_dim_values_in_subgraph = false;
|
||||
|
||||
RunTest(false, options);
|
||||
RunTest(false, options, false);
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ static const ONNX_NAMESPACE::GraphProto CreateSubgraph(const RunOptions& options
|
|||
std::vector<NodeArg*> inputs;
|
||||
std::vector<NodeArg*> outputs;
|
||||
|
||||
/* Subgraph Adds outer_scope_0 to loop_var_0_in,
|
||||
/* Subgraph Adds outer_scope_0 to loop_var_0_in,
|
||||
Concats the iter_num to loop_var_1_in (test loop var that changes shape) so each iteration appends the iter_num
|
||||
to loop_var_1
|
||||
Loop output is the iter_num and sum for that iteration, so each iteration adds a pair to the overall output
|
||||
|
|
@ -103,8 +103,8 @@ static const ONNX_NAMESPACE::GraphProto CreateSubgraph(const RunOptions& options
|
|||
Inputs: iter_num, cond_in, loop_var_in
|
||||
|
||||
iter_num_in loop_var_0_in [outer_scope_0] loop_var_1_in cond_in
|
||||
| | / | (unused)
|
||||
[Cast] [Add]-----/ |
|
||||
| | / | (unused)
|
||||
[Cast] [Add]-----/ |
|
||||
| | | [Constant]
|
||||
iter_num_float sum_0 | sum_0 /
|
||||
| / | \ | \ /
|
||||
|
|
@ -319,9 +319,9 @@ void RunTest(int64_t max_iterations,
|
|||
execution_providers.push_back(DefaultCudaExecutionProvider());
|
||||
execution_providers.push_back(DefaultCpuExecutionProvider());
|
||||
|
||||
test.Run(expect_result, failure_message, {}, nullptr, &execution_providers);
|
||||
test.Run(expect_result, failure_message, {kTensorrtExecutionProvider}, nullptr, &execution_providers);
|
||||
} else {
|
||||
test.Run(expect_result, failure_message);
|
||||
test.Run(expect_result, failure_message, {kTensorrtExecutionProvider});// Disable TensorRT because of unsupported data type INT64
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -395,7 +395,7 @@ TEST(Loop, InfiniteLoopTermination) {
|
|||
std::vector<NodeArg*> outputs;
|
||||
|
||||
/* Never change cond_in so loop is infinite
|
||||
Inputs: iter_num, cond_in, loop carried state variables.
|
||||
Inputs: iter_num, cond_in, loop carried state variables.
|
||||
|
||||
iter_num_in cond_in [outer_scope_0]
|
||||
(unused) | |
|
||||
|
|
@ -478,8 +478,8 @@ TEST(Loop, InfiniteLoopTermination) {
|
|||
std::future<void> terminator_result = task.get_future();
|
||||
std::thread terminator_thread{std::move(task)};
|
||||
|
||||
test.Run(OpTester::ExpectResult::kExpectFailure, "Exiting due to terminate flag being set to true", {},
|
||||
&session_run_options);
|
||||
test.Run(OpTester::ExpectResult::kExpectFailure, "Exiting due to terminate flag being set to true", {kTensorrtExecutionProvider},
|
||||
&session_run_options);// Disable TensorRT on unsupported data type BOOL
|
||||
|
||||
// call get to propagate any exception
|
||||
terminator_result.get();
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ static void CreateSubgraph(Graph& graph, RunOptions& options, const std::string&
|
|||
std::vector<NodeArg*> inputs;
|
||||
std::vector<NodeArg*> outputs;
|
||||
|
||||
/* Subgraph looks like this.
|
||||
/* Subgraph looks like this.
|
||||
|
||||
[constant_1] loop_state_in_1 concat_in_0 concat_in_1
|
||||
\ | \ /
|
||||
|
|
@ -310,7 +310,7 @@ static void RunTest_v8(const std::string test_name, int64_t batch_size, int64_t
|
|||
test.AddOutput<float>("scan_output_2", output_shape, output_2);
|
||||
test.AddOutput<float>("scan_output_3", output_shape, output_3);
|
||||
|
||||
test.Run(expect_result, failure_message);
|
||||
test.Run(expect_result, failure_message, {kTensorrtExecutionProvider});// Disable TensorRT because its parser failed
|
||||
}
|
||||
|
||||
static void RunTest_v9(const std::string test_name, int64_t sequence_len, int64_t input_size,
|
||||
|
|
@ -403,9 +403,9 @@ static void RunTest_v9(const std::string test_name, int64_t sequence_len, int64_
|
|||
execution_providers.push_back(DefaultCudaExecutionProvider());
|
||||
execution_providers.push_back(DefaultCpuExecutionProvider());
|
||||
|
||||
test.Run(expect_result, failure_message, {}, nullptr, &execution_providers);
|
||||
test.Run(expect_result, failure_message, {kTensorrtExecutionProvider}, nullptr, &execution_providers);
|
||||
} else {
|
||||
test.Run(expect_result, failure_message);
|
||||
test.Run(expect_result, failure_message, {kTensorrtExecutionProvider});// Disable TensorRT because its parser failed
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -889,7 +889,7 @@ TEST(Scan9, TransposeOutputDim2) {
|
|||
test.AddInput<float>("scan_input_1", input_shape, {1.0, 2.0});
|
||||
test.AddOutput<float>("scan_output_1", output_shape, {1.0, 2.0});
|
||||
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});// Disable TensorRT on supported data types
|
||||
}
|
||||
|
||||
static void InvalidInput(bool is_v8) {
|
||||
|
|
@ -1081,7 +1081,7 @@ void MixedTypeInputs(bool is_v8) {
|
|||
test.AddOutput<float>("scan_output_1", seq_shape, {0.0, 1.0, 2.0});
|
||||
test.AddOutput<int64_t>("scan_output_2", seq_shape, {0, 1, 2});
|
||||
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});// Disable TensorRT on unsupported data types
|
||||
}
|
||||
|
||||
TEST_8_AND_9(MixedTypeInputs);
|
||||
|
|
@ -1146,7 +1146,7 @@ void UnknownDimInSubgraphOutput(bool is_v8) {
|
|||
test.AddOutput<float>("final_state_1", state_shape, {3.0});
|
||||
test.AddOutput<float>("scan_output_1", seq_shape, {0.0, 1.0, 2.0});
|
||||
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//Disable TensorRT on unknown dimension tests
|
||||
}
|
||||
|
||||
TEST_8_AND_9(UnknownDimInSubgraphOutput);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ TEST(MathOpTest, Add_int32) {
|
|||
test.AddInput<int32_t>("A", {3}, {1, 2, 3});
|
||||
test.AddInput<int32_t>("B", {3}, {4, 5, 6});
|
||||
test.AddOutput<int32_t>("C", {3}, {5, 7, 9});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT parser: elementwise inputs must not be Int32
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Add_int64) {
|
||||
|
|
@ -22,7 +22,7 @@ TEST(MathOpTest, Add_int64) {
|
|||
test.AddInput<int64_t>("A", {3}, {1, 2, 3});
|
||||
test.AddInput<int64_t>("B", {3}, {4, 5, 6});
|
||||
test.AddOutput<int64_t>("C", {3}, {5, 7, 9});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT: INT64 is not supported
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Add) {
|
||||
|
|
@ -68,7 +68,7 @@ TEST(MathOpTest, Add_Broadcast_0x0) {
|
|||
test.AddInput<float>("A", {}, {10.0f});
|
||||
test.AddInput<float>("B", {}, {2.0f});
|
||||
test.AddOutput<float>("C", {}, {12.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT: dynamic shape is not supported
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Add_Broadcast_0x1) {
|
||||
|
|
@ -77,7 +77,7 @@ TEST(MathOpTest, Add_Broadcast_0x1) {
|
|||
test.AddInput<float>("A", {}, {10.0f});
|
||||
test.AddInput<float>("B", {1}, {2.0f});
|
||||
test.AddOutput<float>("C", {1}, {12.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT: dynamic shape is not supported
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Add_Broadcast_1x0) {
|
||||
|
|
@ -86,7 +86,7 @@ TEST(MathOpTest, Add_Broadcast_1x0) {
|
|||
test.AddInput<float>("A", {1}, {10.0f});
|
||||
test.AddInput<float>("B", {}, {2.0f});
|
||||
test.AddOutput<float>("C", {1}, {12.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT: dynamic shape is not supported
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Add_Broadcast_1x1) {
|
||||
|
|
@ -133,7 +133,7 @@ TEST(MathOpTest, Add_Broadcast_2x1x4_1x3x1) {
|
|||
211.0f, 212.0f, 213.0f, 214.0f,
|
||||
221.0f, 222.0f, 223.0f, 224.0f,
|
||||
231.0f, 232.0f, 233.0f, 234.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//Input batch size is inconsistent
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Add_Broadcast_2x1x1_3x4) {
|
||||
|
|
@ -153,7 +153,7 @@ TEST(MathOpTest, Add_Broadcast_2x1x1_3x4) {
|
|||
211.0f, 212.0f, 213.0f, 214.0f,
|
||||
221.0f, 222.0f, 223.0f, 224.0f,
|
||||
231.0f, 232.0f, 233.0f, 234.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//Input batch size is inconsistent
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Sub_int32) {
|
||||
|
|
@ -161,7 +161,7 @@ TEST(MathOpTest, Sub_int32) {
|
|||
test.AddInput<int32_t>("A", {3}, {1, 4, 3});
|
||||
test.AddInput<int32_t>("B", {3}, {4, 2, 4});
|
||||
test.AddOutput<int32_t>("C", {3}, {-3, 2, -1});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT parser:elementwise inputs must not be Int32
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Sub_int64) {
|
||||
|
|
@ -169,7 +169,7 @@ TEST(MathOpTest, Sub_int64) {
|
|||
test.AddInput<int64_t>("A", {3}, {1, 5, 6});
|
||||
test.AddInput<int64_t>("B", {3}, {4, 5, 3});
|
||||
test.AddOutput<int64_t>("C", {3}, {-3, 0, 3});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT: INT64 is not supported
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Sub) {
|
||||
|
|
@ -202,7 +202,7 @@ TEST(MathOpTest, Sub_Broadcast_Scalar) {
|
|||
{-4.0f, -3.0f, -6.0f,
|
||||
-5.0f, -3.5f, -105.0f,
|
||||
-10.4f, 4.3f, -10'005.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT: dynamic shape is not supported
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Mul_int32) {
|
||||
|
|
@ -210,7 +210,7 @@ TEST(MathOpTest, Mul_int32) {
|
|||
test.AddInput<int32_t>("A", {3}, {1, 2, 3});
|
||||
test.AddInput<int32_t>("B", {3}, {4, -3, 6});
|
||||
test.AddOutput<int32_t>("C", {3}, {4, -6, 18});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT parser:elementwise inputs must not be Int32
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Mul_int64) {
|
||||
|
|
@ -218,7 +218,7 @@ TEST(MathOpTest, Mul_int64) {
|
|||
test.AddInput<int64_t>("A", {3}, {3, 6, -3});
|
||||
test.AddInput<int64_t>("B", {3}, {4, -3, -2});
|
||||
test.AddOutput<int64_t>("C", {3}, {12, -18, 6});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT: INT64 is not supported
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Mul) {
|
||||
|
|
@ -244,7 +244,7 @@ TEST(MathOpTest, Div_int32) {
|
|||
test.AddInput<int32_t>("A", {3}, {4, 8, 8});
|
||||
test.AddInput<int32_t>("B", {3}, {1, 3, 2});
|
||||
test.AddOutput<int32_t>("C", {3}, {4, 2, 4});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT parser:elementwise inputs must not be Int32
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Div_int64) {
|
||||
|
|
@ -252,7 +252,7 @@ TEST(MathOpTest, Div_int64) {
|
|||
test.AddInput<int64_t>("A", {3}, {4, 8, 8});
|
||||
test.AddInput<int64_t>("B", {3}, {2, 3, 4});
|
||||
test.AddOutput<int64_t>("C", {3}, {2, 2, 2});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT: INT64 is not supported
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Div) {
|
||||
|
|
@ -283,7 +283,7 @@ TEST(MathOpTest, Abs_int8) {
|
|||
std::vector<int64_t> dims{4};
|
||||
test.AddInput<int8_t>("X", dims, {1, 2, -1, -5});
|
||||
test.AddOutput<int8_t>("Y", dims, {1, 2, 1, 5});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Abs_int32) {
|
||||
|
|
@ -291,7 +291,7 @@ TEST(MathOpTest, Abs_int32) {
|
|||
std::vector<int64_t> dims{4};
|
||||
test.AddInput<int32_t>("X", dims, {1, 2, -1, -5});
|
||||
test.AddOutput<int32_t>("Y", dims, {1, 2, 1, 5});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT parser: Int32 not allowed as input to this layer
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Neg) {
|
||||
|
|
@ -311,7 +311,7 @@ TEST(MathOpTest, Neg_int8) {
|
|||
std::vector<int64_t> dims{4};
|
||||
test.AddInput<int8_t>("X", dims, {1, -2, 0, -10});
|
||||
test.AddOutput<int8_t>("Y", dims, {-1, 2, 0, 10});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Neg_int32) {
|
||||
|
|
@ -319,7 +319,7 @@ TEST(MathOpTest, Neg_int32) {
|
|||
std::vector<int64_t> dims{4};
|
||||
test.AddInput<int32_t>("X", dims, {1, -2, 0, -10});
|
||||
test.AddOutput<int32_t>("Y", dims, {-1, 2, 0, 10});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT parser: Int32 not allowed as input to this layer
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Floor) {
|
||||
|
|
@ -392,7 +392,7 @@ TEST(MathOpTest, Pow_Broadcast_Scalar0) {
|
|||
test.AddInput<float>("X", {}, {2.0f});
|
||||
test.AddInput<float>("Y", dims, {1.0f, 2.0f, 3.0f});
|
||||
test.AddOutput<float>("Z", dims, {2.0f, 4.0f, 8.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT: dynamic shape is not supported
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Pow_Broadcast_Scalar1) {
|
||||
|
|
@ -402,7 +402,7 @@ TEST(MathOpTest, Pow_Broadcast_Scalar1) {
|
|||
test.AddInput<float>("X", dims, {1.0f, 2.0f, 3.0f});
|
||||
test.AddInput<float>("Y", {}, {2.0f});
|
||||
test.AddOutput<float>("Z", dims, {1.0f, 4.0f, 9.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT: dynamic shape is not supported
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Exp) {
|
||||
|
|
@ -415,7 +415,7 @@ TEST(MathOpTest, Exp) {
|
|||
{1.0f, std::exp(1.0f),
|
||||
std::exp(2.0f), std::exp(10.0f)});
|
||||
test.SetOutputRelErr("Y", 1e-7f);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Log) {
|
||||
|
|
@ -469,7 +469,7 @@ TEST(MathOpTest, Sum_8_Test1) {
|
|||
311.0f, 312.0f, 313.0f,
|
||||
321.0f, 322.0f, 323.0f,
|
||||
331.0f, 332.0f, 333.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});// TensorRT parser failed on this test
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Sum_8_Test2) {
|
||||
|
|
@ -498,7 +498,7 @@ TEST(MathOpTest, Sum_8_Test2) {
|
|||
3.3f, 4.4f, -94.7f,
|
||||
59.6f, 64.01f, -8.0f});
|
||||
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "Sum is not correct");
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "Sum is not correct", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Min_6) {
|
||||
|
|
@ -581,7 +581,7 @@ TEST(MathOpTest, Max_8) {
|
|||
{10.0f, 20.0f, 30.0f,
|
||||
40.0f, 50.0f, 60.0f,
|
||||
300.0f, 300.0f, 300.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//Input batch size is inconsistent
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Not) {
|
||||
|
|
@ -757,7 +757,7 @@ TEST(MathOpTest, Mean_8) {
|
|||
{12.0f / 3.0f, 22.0f / 3.0f, 32.0f / 3.0f,
|
||||
43.0f / 3.0f, 53.0f / 3.0f, 63.0f / 3.0f,
|
||||
74.0f / 3.0f, 84.0f / 3.0f, 94.0f / 3.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//Input batch size is inconsistent
|
||||
}
|
||||
|
||||
#ifndef DISABLE_CONTRIB_OPS
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
namespace onnxruntime {
|
||||
namespace test {
|
||||
|
||||
// Disable TensorRT on some of the tests because TensorRT only support FLOAT, INT8, FLOAT16 and INT32 for now
|
||||
|
||||
TEST(GemmOpTest, GemmNoTrans) {
|
||||
OpTester test("Gemm");
|
||||
|
||||
|
|
@ -23,7 +25,7 @@ TEST(GemmOpTest, GemmNoTrans) {
|
|||
test.AddOutput<float>("Y", {2, 3},
|
||||
{11.0f, 11.0f, 11.0f,
|
||||
-9.0f, -9.0f, -9.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
// Only CUDA kernel has float 16 support
|
||||
|
|
@ -56,7 +58,7 @@ TEST(GemmOpTest, GemmNoTrans_f16) {
|
|||
test.AddInput<MLFloat16>("B", {4, 3}, f_B);
|
||||
test.AddInput<MLFloat16>("C", {2, 3}, f_C);
|
||||
test.AddOutput<MLFloat16>("Y", {2, 3}, f_Y);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -76,7 +78,7 @@ TEST(GemmOpTest, GemmBroadcast) {
|
|||
test.AddOutput<float>("Y", {2, 3},
|
||||
{11.0f, 12.0f, 13.0f,
|
||||
-9.0f, -8.0f, -7.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GemmOpTest, GemmTrans) {
|
||||
|
|
@ -97,7 +99,7 @@ TEST(GemmOpTest, GemmTrans) {
|
|||
test.AddOutput<float>("Y", {2, 3},
|
||||
{11.0f, 11.0f, 11.0f,
|
||||
-9.0f, -9.0f, -9.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GemmOpTest, GemmAlphaBeta) {
|
||||
|
|
@ -116,7 +118,7 @@ TEST(GemmOpTest, GemmAlphaBeta) {
|
|||
test.AddOutput<float>("Y", {2, 3},
|
||||
{7.0f, 7.0f, 7.0f,
|
||||
-3.0f, -3.0f, -3.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GemmOpTest, GemmNaN) {
|
||||
|
|
@ -135,7 +137,7 @@ TEST(GemmOpTest, GemmNaN) {
|
|||
test.AddOutput<float>("Y", {2, 3},
|
||||
{10.0f, 10.0f, 10.0f,
|
||||
-10.0f, -10.0f, -10.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GemmOpTest, GemmScalarBroadcast) {
|
||||
|
|
@ -154,7 +156,7 @@ TEST(GemmOpTest, GemmScalarBroadcast) {
|
|||
test.AddOutput<float>("Y", {2, 3},
|
||||
{11.0f, 11.0f, 11.0f,
|
||||
-9.0f, -9.0f, -9.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Gemm2DBroadcast) {
|
||||
|
|
@ -173,7 +175,7 @@ TEST(MathOpTest, Gemm2DBroadcast) {
|
|||
test.AddOutput<float>("Y", {2, 3},
|
||||
{11.0f, 11.0f, 11.0f,
|
||||
-8.0f, -8.0f, -8.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GemmOpTest, GemmFalseBroadcast) {
|
||||
|
|
@ -192,7 +194,7 @@ TEST(GemmOpTest, GemmFalseBroadcast) {
|
|||
test.AddOutput<float>("Y", {2, 3},
|
||||
{11.0f, 11.0f, 11.0f,
|
||||
-8.0f, -8.0f, -8.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GemmOpTest, GemmEmptyTensor) {
|
||||
|
|
@ -209,7 +211,7 @@ TEST(GemmOpTest, GemmEmptyTensor) {
|
|||
test.AddInput<float>("C", {3}, std::vector<float>(3, 1.0f));
|
||||
test.AddOutput<float>("Y", {0, 3},
|
||||
{});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ static void RunTest(const std::vector<float>& x_vals,
|
|||
const std::vector<float>& expected_vals,
|
||||
const std::vector<int64_t>& dimensions,
|
||||
int64_t axis = 1,
|
||||
bool is_tensorrt_supported = true,
|
||||
OpTester::ExpectResult expect_result = OpTester::ExpectResult::kExpectSuccess,
|
||||
const std::string& error_msg = "") {
|
||||
OpTester tester("LogSoftmax");
|
||||
|
|
@ -24,7 +25,11 @@ static void RunTest(const std::vector<float>& x_vals,
|
|||
tester.AddInput("X", dimensions, x_vals);
|
||||
tester.AddOutput("Y", dimensions, expected_vals);
|
||||
|
||||
tester.Run(expect_result, error_msg);
|
||||
std::unordered_set<std::string> excluded_providers;
|
||||
if (!is_tensorrt_supported) {
|
||||
excluded_providers.insert(kTensorrtExecutionProvider);
|
||||
}
|
||||
tester.Run(expect_result, error_msg, excluded_providers);
|
||||
}
|
||||
|
||||
TEST(LogSoftmaxOperator, Simple) {
|
||||
|
|
@ -96,7 +101,7 @@ TEST(LogSoftmaxOperator, ThreeDimsAxis0) {
|
|||
-4.042971f, -4.2982683f, -3.5933442f, -4.538994f, -5.307373f,
|
||||
-4.2677402f, -4.44635f, -3.5821702f, -3.8414123f, -4.267664f};
|
||||
|
||||
RunTest(x_vals_3dims, expected_vals, three_dimensions, /*axis*/ 0);
|
||||
RunTest(x_vals_3dims, expected_vals, three_dimensions, /*axis*/ 0, false);// axis=0 is not supported by TensorRT
|
||||
}
|
||||
|
||||
TEST(LogSoftmaxOperator, ThreeDimsAxis1) {
|
||||
|
|
@ -122,7 +127,7 @@ TEST(LogSoftmaxOperator, ThreeDimsAxis1) {
|
|||
-2.9822054f, -3.2375026f, -2.5325785f, -3.4782279f, -4.246608f,
|
||||
-3.2069747f, -3.3855844f, -2.5214045f, -2.7806466f, -3.206898f};
|
||||
|
||||
RunTest(x_vals_3dims, expected_vals, three_dimensions, /*axis*/ 1);
|
||||
RunTest(x_vals_3dims, expected_vals, three_dimensions, /*axis*/ 1, false);// This test failed on TensorRT
|
||||
}
|
||||
|
||||
TEST(LogSoftmaxOperator, ThreeDimsAxis2) {
|
||||
|
|
@ -187,8 +192,9 @@ TEST(LogSoftmaxOperator, InvalidAxis) {
|
|||
expected_vals,
|
||||
dimensions,
|
||||
/* invalid axis */ -7,
|
||||
false,
|
||||
OpTester::ExpectResult::kExpectFailure,
|
||||
"-7 is not in valid range [-2,1]");
|
||||
"-7 is not in valid range [-2,1]");//TensorRT parser: Assertion failed: axis >= 0 && axis < nbDims
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ struct MatMulTestData {
|
|||
};
|
||||
|
||||
template <typename T>
|
||||
std::vector<MatMulTestData<T>> GenerateTestCases()
|
||||
std::vector<MatMulTestData<T>> GenerateTestCases()
|
||||
{
|
||||
std::vector<MatMulTestData<T>> test_cases;
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ std::vector<MatMulTestData<T>> GenerateTestCases()
|
|||
{2},
|
||||
{3, 1},
|
||||
{1, 3, 5}});
|
||||
|
||||
|
||||
test_cases.push_back(
|
||||
{"test scalar output",
|
||||
{3},
|
||||
|
|
@ -96,16 +96,17 @@ void RunMatMulTest(int32_t opset_version = 7)
|
|||
test.AddInput<T>("B", t.input1_dims, input1_vals);
|
||||
|
||||
test.AddOutput<T>("Y", t.expected_dims, t.expected_vals);
|
||||
test.Run();
|
||||
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});// Disable TensorRT because of unsupported data type
|
||||
}
|
||||
}
|
||||
|
||||
TEST(MathOpTest, MatMulFloatType) {
|
||||
RunMatMulTest<float>();
|
||||
RunMatMulTest<float>(7);
|
||||
}
|
||||
|
||||
TEST(MathOpTest, MatMulDoubleType) {
|
||||
RunMatMulTest<double>();
|
||||
RunMatMulTest<double>(7);
|
||||
}
|
||||
|
||||
TEST(MathOpTest, MatMulInt32Type) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ static void RunTest(const std::vector<float>& x_vals,
|
|||
const std::vector<float>& expected_vals,
|
||||
const std::vector<int64_t>& dimensions,
|
||||
int64_t axis = 1,
|
||||
bool is_tensorrt_supported = true,
|
||||
OpTester::ExpectResult expect_result = OpTester::ExpectResult::kExpectSuccess,
|
||||
const std::string& error_msg = "") {
|
||||
OpTester test("Softmax");
|
||||
|
|
@ -23,7 +24,11 @@ static void RunTest(const std::vector<float>& x_vals,
|
|||
|
||||
test.AddInput<float>("X", dimensions, x_vals);
|
||||
test.AddOutput<float>("Y", dimensions, expected_vals);
|
||||
test.Run(expect_result, error_msg);
|
||||
std::unordered_set<std::string> excluded_providers;
|
||||
if (!is_tensorrt_supported) {
|
||||
excluded_providers.insert(kTensorrtExecutionProvider);
|
||||
}
|
||||
test.Run(expect_result, error_msg, excluded_providers);
|
||||
}
|
||||
|
||||
TEST(SoftmaxOperator, Simple) {
|
||||
|
|
@ -92,7 +97,7 @@ TEST(SoftmaxOperator, ThreeDimsAxis0) {
|
|||
0.017545262f, 0.0135920765f, 0.027506188f, 0.010684152f, 0.0049549243f,
|
||||
0.01401341f, 0.011721271f, 0.027815264f, 0.021463264f, 0.014014485f};
|
||||
|
||||
RunTest(x_vals_3dims, expected_vals, three_dimensions, /*axis*/ 0);
|
||||
RunTest(x_vals_3dims, expected_vals, three_dimensions, /*axis*/ 0, false);// Axis=0 is not supported by TensorRT
|
||||
}
|
||||
|
||||
TEST(SoftmaxOperator, ThreeDimsAxis1) {
|
||||
|
|
@ -118,7 +123,7 @@ TEST(SoftmaxOperator, ThreeDimsAxis1) {
|
|||
0.050680935f, 0.03926183f, 0.079453886f, 0.030862054f, 0.014312706f,
|
||||
0.040478885f, 0.033857856f, 0.080346674f, 0.06199841f, 0.040481992f};
|
||||
|
||||
RunTest(x_vals_3dims, expected_vals, three_dimensions, /*axis*/ 1);
|
||||
RunTest(x_vals_3dims, expected_vals, three_dimensions, /*axis*/ 1, false);
|
||||
}
|
||||
|
||||
TEST(SoftmaxOperator, ThreeDimsAxis2) {
|
||||
|
|
@ -182,7 +187,7 @@ TEST(SoftmaxOperator, InvalidAxis) {
|
|||
RunTest(x_vals,
|
||||
expected_vals,
|
||||
dimensions,
|
||||
/* invalid axis */ -10,
|
||||
/* invalid axis */ -10, false,
|
||||
OpTester::ExpectResult::kExpectFailure,
|
||||
"-10 is not in valid range [-2,1]");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ static void RunTest(int op_set,
|
|||
const std::vector<float>& expected_vals,
|
||||
const std::vector<int64_t>& expected_indices,
|
||||
const std::vector<int64_t>& expected_dimensions,
|
||||
bool is_tensorrt_supported = true,
|
||||
int64_t axis = -1,
|
||||
OpTester::ExpectResult expect_result = OpTester::ExpectResult::kExpectSuccess,
|
||||
const std::string& expected_err_str = "") {
|
||||
|
|
@ -36,7 +37,11 @@ static void RunTest(int op_set,
|
|||
test.AddOutput<int64_t>("Indices", expected_dimensions, expected_indices);
|
||||
|
||||
// Run test and check results
|
||||
test.Run(expect_result, expected_err_str);
|
||||
std::unordered_set<std::string> excluded_providers;
|
||||
if (!is_tensorrt_supported) {
|
||||
excluded_providers.insert(kTensorrtExecutionProvider);//Disable TensorRT because of unsupported data types
|
||||
}
|
||||
test.Run(expect_result, expected_err_str, excluded_providers);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, Top1DefaultAxisOpset9) {
|
||||
|
|
@ -45,7 +50,7 @@ TEST(TopKOperator, Top1DefaultAxisOpset9) {
|
|||
std::vector<float> expected_vals = {0.4f, 0.3f};
|
||||
std::vector<int64_t> expected_indices = {3, 1};
|
||||
std::vector<int64_t> expected_dimensions = {2, 1};
|
||||
RunTest(9, 1, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions);
|
||||
RunTest(9, 1, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, Top2DefaultAxisOpset9) {
|
||||
|
|
@ -54,7 +59,7 @@ TEST(TopKOperator, Top2DefaultAxisOpset9) {
|
|||
std::vector<float> expected_vals = {0.4f, 0.3f, 0.4f, 0.3f};
|
||||
std::vector<int64_t> expected_indices = {3, 1, 2, 1};
|
||||
std::vector<int64_t> expected_dimensions = {2, 2};
|
||||
RunTest(9, 2, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions);
|
||||
RunTest(9, 2, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, Top3DefaultAxisOpset9) {
|
||||
|
|
@ -63,7 +68,7 @@ TEST(TopKOperator, Top3DefaultAxisOpset9) {
|
|||
std::vector<float> expected_vals = {0.4f, 0.3f, 0.2f, 0.4f, 0.3f, 0.2f};
|
||||
std::vector<int64_t> expected_indices = {3, 1, 2, 2, 1, 3};
|
||||
std::vector<int64_t> expected_dimensions = {2, 3};
|
||||
RunTest(9, 3, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions);
|
||||
RunTest(9, 3, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, TopAllDefaultAxisOpset9) {
|
||||
|
|
@ -72,7 +77,7 @@ TEST(TopKOperator, TopAllDefaultAxisOpset9) {
|
|||
std::vector<float> expected_vals = {0.4f, 0.3f, 0.2f, 0.1f, 0.3f, 0.3f, 0.2f, 0.1f};
|
||||
std::vector<int64_t> expected_indices = {3, 1, 2, 0, 1, 2, 3, 0};
|
||||
std::vector<int64_t> expected_dimensions = {2, 4};
|
||||
RunTest(9, 4, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions);
|
||||
RunTest(9, 4, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, Top1ExplicitAxisOpset9) {
|
||||
|
|
@ -82,7 +87,7 @@ TEST(TopKOperator, Top1ExplicitAxisOpset9) {
|
|||
std::vector<int64_t> expected_indices = {3, 1};
|
||||
std::vector<int64_t> expected_dimensions = {1, 2};
|
||||
int64_t axis = 0;
|
||||
RunTest(9, 1, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, axis);
|
||||
RunTest(9, 1, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false, axis);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, Top2ExplicitAxisOpset9) {
|
||||
|
|
@ -92,7 +97,7 @@ TEST(TopKOperator, Top2ExplicitAxisOpset9) {
|
|||
std::vector<int64_t> expected_indices = {1, 2, 2, 0, 2, 1, 1, 1};
|
||||
std::vector<int64_t> expected_dimensions = {2, 4};
|
||||
int64_t axis = 0;
|
||||
RunTest(9, 2, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, axis);
|
||||
RunTest(9, 2, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false, axis);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, Top3ExplicitAxisOpset9) {
|
||||
|
|
@ -102,7 +107,7 @@ TEST(TopKOperator, Top3ExplicitAxisOpset9) {
|
|||
std::vector<int64_t> expected_indices = {3, 1, 1, 0, 0, 2};
|
||||
std::vector<int64_t> expected_dimensions = {3, 2};
|
||||
int64_t axis = 0;
|
||||
RunTest(9, 3, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, axis);
|
||||
RunTest(9, 3, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false, axis);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, TopAllExplicitAxisOpset9) {
|
||||
|
|
@ -112,7 +117,7 @@ TEST(TopKOperator, TopAllExplicitAxisOpset9) {
|
|||
std::vector<int64_t> expected_indices = {3, 1, 1, 0, 0, 2, 2, 3};
|
||||
std::vector<int64_t> expected_dimensions = {4, 2};
|
||||
int64_t axis = 0;
|
||||
RunTest(9, 4, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, axis);
|
||||
RunTest(9, 4, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false, axis);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, TopAllExplicitAxis1DInputOpset9) {
|
||||
|
|
@ -122,7 +127,7 @@ TEST(TopKOperator, TopAllExplicitAxis1DInputOpset9) {
|
|||
std::vector<int64_t> expected_indices = {7, 3, 2, 12, 9, 1, 8, 11, 4, 10, 5, 6, 0};
|
||||
std::vector<int64_t> expected_dimensions = {13};
|
||||
int64_t axis = 0;
|
||||
RunTest(9, 13, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, axis);
|
||||
RunTest(9, 13, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false, axis);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, Top1ExplicitAxisMultiDInputOpset9) {
|
||||
|
|
@ -132,7 +137,7 @@ TEST(TopKOperator, Top1ExplicitAxisMultiDInputOpset9) {
|
|||
std::vector<int64_t> expected_indices = {1, 1, 1, 1};
|
||||
std::vector<int64_t> expected_dimensions = {2, 1, 2};
|
||||
int64_t axis = 1;
|
||||
RunTest(9, 1, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, axis);
|
||||
RunTest(9, 1, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false, axis);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, InvalidKOpset9) {
|
||||
|
|
@ -148,6 +153,7 @@ TEST(TopKOperator, InvalidKOpset9) {
|
|||
expected_vals,
|
||||
expected_indices,
|
||||
expected_dimensions,
|
||||
true,
|
||||
1,
|
||||
OpTester::ExpectResult::kExpectFailure,
|
||||
"Invalid value for attribute k");
|
||||
|
|
@ -159,7 +165,7 @@ TEST(TopKOperator, Top1DefaultAxisOpset10) {
|
|||
std::vector<float> expected_vals = {0.4f, 0.3f};
|
||||
std::vector<int64_t> expected_indices = {3, 1};
|
||||
std::vector<int64_t> expected_dimensions = {2, 1};
|
||||
RunTest(10, 1, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions);
|
||||
RunTest(10, 1, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, Top2DefaultAxisOpset10) {
|
||||
|
|
@ -168,7 +174,7 @@ TEST(TopKOperator, Top2DefaultAxisOpset10) {
|
|||
std::vector<float> expected_vals = {0.4f, 0.3f, 0.4f, 0.3f};
|
||||
std::vector<int64_t> expected_indices = {3, 1, 2, 1};
|
||||
std::vector<int64_t> expected_dimensions = {2, 2};
|
||||
RunTest(10, 2, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions);
|
||||
RunTest(10, 2, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, Top3DefaultAxisOpset10) {
|
||||
|
|
@ -177,7 +183,7 @@ TEST(TopKOperator, Top3DefaultAxisOpset10) {
|
|||
std::vector<float> expected_vals = {0.4f, 0.3f, 0.2f, 0.4f, 0.3f, 0.2f};
|
||||
std::vector<int64_t> expected_indices = {3, 1, 2, 2, 1, 3};
|
||||
std::vector<int64_t> expected_dimensions = {2, 3};
|
||||
RunTest(10, 3, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions);
|
||||
RunTest(10, 3, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, TopAllDefaultAxisOpset10) {
|
||||
|
|
@ -186,7 +192,7 @@ TEST(TopKOperator, TopAllDefaultAxisOpset10) {
|
|||
std::vector<float> expected_vals = {0.4f, 0.3f, 0.2f, 0.1f, 0.3f, 0.3f, 0.2f, 0.1f};
|
||||
std::vector<int64_t> expected_indices = {3, 1, 2, 0, 1, 2, 3, 0};
|
||||
std::vector<int64_t> expected_dimensions = {2, 4};
|
||||
RunTest(10, 4, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions);
|
||||
RunTest(10, 4, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, Top1ExplicitAxisOpset10) {
|
||||
|
|
@ -196,7 +202,7 @@ TEST(TopKOperator, Top1ExplicitAxisOpset10) {
|
|||
std::vector<int64_t> expected_indices = {3, 1};
|
||||
std::vector<int64_t> expected_dimensions = {1, 2};
|
||||
int64_t axis = 0;
|
||||
RunTest(10, 1, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, axis);
|
||||
RunTest(10, 1, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false, axis);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, Top2ExplicitAxisOpset10) {
|
||||
|
|
@ -206,7 +212,7 @@ TEST(TopKOperator, Top2ExplicitAxisOpset10) {
|
|||
std::vector<int64_t> expected_indices = {1, 2, 2, 0, 2, 1, 1, 1};
|
||||
std::vector<int64_t> expected_dimensions = {2, 4};
|
||||
int64_t axis = 0;
|
||||
RunTest(10, 2, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, axis);
|
||||
RunTest(10, 2, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false, axis);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, Top3ExplicitAxisOpset10) {
|
||||
|
|
@ -216,7 +222,7 @@ TEST(TopKOperator, Top3ExplicitAxisOpset10) {
|
|||
std::vector<int64_t> expected_indices = {3, 1, 1, 0, 0, 2};
|
||||
std::vector<int64_t> expected_dimensions = {3, 2};
|
||||
int64_t axis = 0;
|
||||
RunTest(10, 3, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, axis);
|
||||
RunTest(10, 3, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false, axis);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, TopAllExplicitAxisOpset10) {
|
||||
|
|
@ -226,7 +232,7 @@ TEST(TopKOperator, TopAllExplicitAxisOpset10) {
|
|||
std::vector<int64_t> expected_indices = {3, 1, 1, 0, 0, 2, 2, 3};
|
||||
std::vector<int64_t> expected_dimensions = {4, 2};
|
||||
int64_t axis = 0;
|
||||
RunTest(10, 4, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, axis);
|
||||
RunTest(10, 4, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false, axis);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, TopAllExplicitAxis1DInputOpset10) {
|
||||
|
|
@ -236,7 +242,7 @@ TEST(TopKOperator, TopAllExplicitAxis1DInputOpset10) {
|
|||
std::vector<int64_t> expected_indices = {7, 3, 2, 12, 9, 1, 8, 11, 4, 10, 5, 6, 0};
|
||||
std::vector<int64_t> expected_dimensions = {13};
|
||||
int64_t axis = 0;
|
||||
RunTest(10, 13, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, axis);
|
||||
RunTest(10, 13, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false, axis);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, Top1ExplicitAxisMultiDInputOpset10) {
|
||||
|
|
@ -246,7 +252,7 @@ TEST(TopKOperator, Top1ExplicitAxisMultiDInputOpset10) {
|
|||
std::vector<int64_t> expected_indices = {1, 1, 1, 1};
|
||||
std::vector<int64_t> expected_dimensions = {2, 1, 2};
|
||||
int64_t axis = 1;
|
||||
RunTest(10, 1, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, axis);
|
||||
RunTest(10, 1, input_vals, input_dimensions, expected_vals, expected_indices, expected_dimensions, false, axis);
|
||||
}
|
||||
|
||||
TEST(TopKOperator, InvalidKOpset10) {
|
||||
|
|
@ -262,10 +268,11 @@ TEST(TopKOperator, InvalidKOpset10) {
|
|||
expected_vals,
|
||||
expected_indices,
|
||||
expected_dimensions,
|
||||
false,
|
||||
1,
|
||||
OpTester::ExpectResult::kExpectFailure,
|
||||
"value of k should be greater than 0");
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
} // namespace onnxruntime
|
||||
} // namespace onnxruntime
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ void TestBatchNorm(const InputDataMap& input_data_map,
|
|||
test.AddInput<float>("mean", input_shapes_map.at("mean"), input_data_map.at("mean"));
|
||||
test.AddInput<float>("var", input_shapes_map.at("var"), input_data_map.at("var"));
|
||||
test.AddOutput<float>("output", expected_output_shape, expected_output);
|
||||
test.Run(expect_result, err_str);
|
||||
test.Run(expect_result, err_str, {kTensorrtExecutionProvider});// Weight as input is not supported by TensorRT
|
||||
}
|
||||
|
||||
TEST(BatchNormTest, PositiveTestCase) {
|
||||
|
|
@ -601,7 +601,7 @@ TEST(BatchNormTest, BatchNorm2d_fp16) {
|
|||
test.AddInput<MLFloat16>("mean", {3}, f_mean);
|
||||
test.AddInput<MLFloat16>("var", {3}, f_var);
|
||||
test.AddOutput<MLFloat16>("output", input_shape, f_output);
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "");
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ void TestConvOp(const ConvOpAttributes& attributes,
|
|||
if (!is_mkldnn_supported) {
|
||||
excluded_providers.insert(kMklDnnExecutionProvider);
|
||||
}
|
||||
excluded_providers.insert(kTensorrtExecutionProvider);// Disable TensorRT because weight as input is not supported
|
||||
test.Run(expect_result, err_str, excluded_providers);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ void TestConvTransposeOp(const ConvTransposeOpAttributes& attributes,
|
|||
test.AddInput<float>(szNames[i], input_shapes[i], inputs[i]);
|
||||
}
|
||||
test.AddOutput<float>("Y", expected_output_shape, expected_output);
|
||||
test.Run(expect_result, err_str);
|
||||
test.Run(expect_result, err_str, {kTensorrtExecutionProvider});// Disable TensorRT because weight as input is not supported
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
|
@ -247,7 +247,7 @@ TEST(ConvTransposeTest, ConvTranspose_InvalidKernelShape) {
|
|||
vector<int64_t>{2, 1, 1, 14}, // output_shape
|
||||
vector<int64_t>{0, 0, 0, 0}, // pads
|
||||
vector<int64_t>{1, 1}, // strides
|
||||
vector<int64_t>{1, 1}, // dilations
|
||||
vector<int64_t>{1, 1}, // dilations
|
||||
1 // group
|
||||
};
|
||||
vector<float> X = {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f,
|
||||
|
|
@ -302,7 +302,7 @@ TEST(ConvTransposeTest, ConvTranspose_onnx2) {
|
|||
{}, // output_shape
|
||||
vector<int64_t>{0, 0, 0, 0}, // pads
|
||||
vector<int64_t>{1, 1}, // strides
|
||||
vector<int64_t>{1, 1}, // dilations
|
||||
vector<int64_t>{1, 1}, // dilations
|
||||
1 // group
|
||||
};
|
||||
vector<float> X = {0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17.};
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
namespace onnxruntime {
|
||||
namespace test {
|
||||
|
||||
// Disable TensorRT on some of the tests because axis=0 is not supported
|
||||
|
||||
class FlattenOpTest : public testing::Test {
|
||||
public:
|
||||
FlattenOpTest() : test_("Flatten"), data0_(120, 1.0f) {}
|
||||
|
|
@ -24,7 +26,7 @@ TEST_F(FlattenOpTest, Flatten_axis0) {
|
|||
test_.AddAttribute<int64_t>("axis", 0L);
|
||||
test_.AddInput<float>("data", {2L, 3L, 4L, 5L}, data0_);
|
||||
test_.AddOutput<float>("output", {1L, 120L}, data0_);
|
||||
test_.Run();
|
||||
test_.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST_F(FlattenOpTest, Flatten_default_axis) {
|
||||
|
|
@ -45,14 +47,14 @@ TEST_F(FlattenOpTest, Flatten_axis3) {
|
|||
test_.AddAttribute<int64_t>("axis", 3L);
|
||||
test_.AddInput<float>("data", {2L, 3L, 4L, 5L}, data0_);
|
||||
test_.AddOutput<float>("output", {24L, 5L}, data0_);
|
||||
test_.Run();
|
||||
test_.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST_F(FlattenOpTest, Flatten_axis4) {
|
||||
test_.AddAttribute<int64_t>("axis", 4L);
|
||||
test_.AddInput<float>("data", {1L, 2L, 4L, 2L}, data1_);
|
||||
test_.AddOutput<float>("output", {16L, 1L}, data1_);
|
||||
test_.Run();
|
||||
test_.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
} // namespace test
|
||||
} // namespace onnxruntime
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ using namespace std;
|
|||
namespace onnxruntime {
|
||||
namespace test {
|
||||
|
||||
// Disable TensorRT on some of the tests because its parser doesn't support weight as input
|
||||
|
||||
TEST(InstanceNormalizationOpTest, InstanceNorm) {
|
||||
OpTester test("InstanceNormalization");
|
||||
test.AddAttribute("epsilon", 0.3F);
|
||||
|
|
@ -39,7 +41,7 @@ TEST(InstanceNormalizationOpTest, InstanceNorm) {
|
|||
-0.14644464F, -0.82262872F, -0.66852817F, 1.63760153F,
|
||||
-1.65898662F, 0.27618144F, 0.64840618F, 0.734399F};
|
||||
test.AddOutput<float>("Y", input_dims, expected_output);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(InstanceNormalizationOpTest, InstanceNormBatch1) {
|
||||
|
|
@ -66,7 +68,7 @@ TEST(InstanceNormalizationOpTest, InstanceNormBatch1) {
|
|||
1.46688162F, -0.98600774F, -0.79911913F, 0.31824524F,
|
||||
0.57370438F, 0.42193634F, 0.6525492F, -1.64818992F};
|
||||
test.AddOutput<float>("Y", input_dims, expected_output);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(InstanceNormalizationOpTest, InstanceNorm_2) {
|
||||
|
|
@ -109,7 +111,7 @@ TEST(InstanceNormalizationOpTest, InstanceNorm_2) {
|
|||
1.88028F, 2.353724F, -0.25549555F,
|
||||
2.0837004F, 2.8466992F, 2.0773761F};
|
||||
test.AddOutput<float>("Y", input_dims, expected_output);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ using namespace std;
|
|||
namespace onnxruntime {
|
||||
namespace test {
|
||||
|
||||
// Disable TensorRT on some of the tests because "pads" attribute is not supported
|
||||
|
||||
TEST(PoolTest, MaxPool) {
|
||||
OpTester test("MaxPool");
|
||||
|
||||
|
|
@ -49,7 +51,7 @@ TEST(PoolTest, MaxPool) {
|
|||
|
||||
test.AddInput<float>("X", x_dims, x_vals);
|
||||
test.AddOutput<float>("Y", expected_dims, expected_vals);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
// Only CUDA kernel has float 16 support
|
||||
|
|
@ -102,7 +104,7 @@ TEST(PoolTest, MaxPool_F16) {
|
|||
|
||||
test.AddInput<MLFloat16>("X", x_dims, f_X);
|
||||
test.AddOutput<MLFloat16>("Y", expected_dims, f_Y);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -154,7 +156,7 @@ static void MaxPool_8_WithIndexTest(bool has_index, int64_t storage_order=0) {
|
|||
storage_order == 0 ? test.AddOutput<int64_t>("Indices", expected_dims, expected_indices_row)
|
||||
: test.AddOutput<int64_t>("Indices", expected_dims, expected_indices_col);
|
||||
}
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kMklDnnExecutionProvider});
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kMklDnnExecutionProvider, kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(PoolTest, MaxPool_8_With_Index) {
|
||||
|
|
@ -178,7 +180,7 @@ TEST(PoolTest, MaxPool1D) {
|
|||
|
||||
test.AddInput<float>("X", x_dims, x_vals);
|
||||
test.AddOutput<float>("Y", expected_dims, expected_vals);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
static void MaxPool1D_8_WithIndexTest(int64_t storage_order) {
|
||||
|
|
@ -199,7 +201,7 @@ static void MaxPool1D_8_WithIndexTest(int64_t storage_order) {
|
|||
test.AddInput<float>("X", x_dims, x_vals);
|
||||
test.AddOutput<float>("Y", expected_dims, expected_vals);
|
||||
test.AddOutput<int64_t>("Indices", expected_dims, expected_indices);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(PoolTest, MaxPool1D_8_With_Index) {
|
||||
|
|
@ -356,7 +358,7 @@ TEST(PoolTest, GlobalMaxPool3D) {
|
|||
|
||||
test.AddInput<float>("X", x_dims, x_vals);
|
||||
test.AddOutput<float>("Y", expected_dims, expected_vals);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(PoolTest, AveragePool) {
|
||||
|
|
@ -437,7 +439,7 @@ TEST(PoolTest, AveragePool) {
|
|||
|
||||
test.AddInput<float>("X", x_dims, x_vals);
|
||||
test.AddOutput<float>("Y", expected_dims, expected_vals);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(PoolTest, AveragePool_IncludePadPixel) {
|
||||
|
|
@ -461,7 +463,7 @@ TEST(PoolTest, AveragePool_IncludePadPixel) {
|
|||
|
||||
test.AddInput<float>("X", x_dims, x_vals);
|
||||
test.AddOutput<float>("Y", expected_dims, expected_vals);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(PoolTest, GlobalAveragePool) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
namespace onnxruntime {
|
||||
namespace test {
|
||||
|
||||
// Disable TensorRT on some of the tests because the limit in its parser: axis >=0 && axis < nbDims
|
||||
|
||||
template <typename OutT>
|
||||
void TestReduceOp(const std::string& op,
|
||||
const std::vector<int64_t>& input_dims,
|
||||
|
|
@ -29,7 +31,7 @@ void TestReduceOp(const std::string& op,
|
|||
test.AddAttribute("keepdims", keepdims);
|
||||
test.AddInput<float>("data", input_dims, data);
|
||||
test.AddOutput<OutT>("reduced", expected_dims, expected_data);
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kCudaExecutionProvider});
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kCudaExecutionProvider, kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReductionVariationTest) {
|
||||
|
|
@ -67,7 +69,7 @@ TEST(ReductionOpTest, ReduceL1_default_axes_keepdims) {
|
|||
9.0f, 10.0f,
|
||||
11.0f, 12.0f});
|
||||
test.AddOutput<float>("reduced", {1, 1, 1}, {78.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceL1_do_not_keepdims) {
|
||||
|
|
@ -94,7 +96,7 @@ TEST(ReductionOpTest, ReduceL1_do_not_keepdims_2) {
|
|||
test.AddInput<float>("data", {3},
|
||||
{1.0f, 2.0f, 3.0f});
|
||||
test.AddOutput<float>("reduced", {}, {6.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceL1_keepdims) {
|
||||
|
|
@ -127,7 +129,7 @@ TEST(ReductionOpTest, ReduceL1) {
|
|||
9.0f, 10.0f,
|
||||
11.0f, 12.0f});
|
||||
test.AddOutput<float>("reduced", {1, 2, 1}, {33.0f, 45.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceL1_int32) {
|
||||
|
|
@ -143,7 +145,7 @@ TEST(ReductionOpTest, ReduceL1_int32) {
|
|||
9, 10,
|
||||
11, 12});
|
||||
test.AddOutput<int32_t>("reduced", {1, 2, 1}, {33, 45});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceL2_default_axes_keepdims) {
|
||||
|
|
@ -159,7 +161,7 @@ TEST(ReductionOpTest, ReduceL2_default_axes_keepdims) {
|
|||
9.0f, 10.0f,
|
||||
11.0f, 12.0f});
|
||||
test.AddOutput<float>("reduced", {1, 1, 1}, {25.49509757f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceL2_do_not_keepdims) {
|
||||
|
|
@ -186,7 +188,7 @@ TEST(ReductionOpTest, ReduceL2_do_not_keepdims_2) {
|
|||
test.AddInput<float>("data", {3},
|
||||
{1.0f, 2.0f, 3.0f});
|
||||
test.AddOutput<float>("reduced", {}, {3.741657387f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceL2_keepdims) {
|
||||
|
|
@ -220,7 +222,7 @@ TEST(ReductionOpTest, ReduceL2) {
|
|||
9.0f, 10.0f,
|
||||
11.0f, 12.0f});
|
||||
test.AddOutput<float>("reduced", {2}, {15.71623325f, 20.07485962f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceL2_int32) {
|
||||
|
|
@ -237,7 +239,7 @@ TEST(ReductionOpTest, ReduceL2_int32) {
|
|||
9, 10,
|
||||
11, 12});
|
||||
test.AddOutput<int32_t>("reduced", {2}, {15, 20});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceLogSum) {
|
||||
|
|
@ -278,7 +280,7 @@ TEST(ReductionOpTest, ReduceLogSum_do_not_keepdims_2) {
|
|||
test.AddInput<float>("data", {3},
|
||||
{1.0f, 2.0f, 3.0f});
|
||||
test.AddOutput<float>("reduced", {}, {1.79175947f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceLogSumExp_default_axes_keepdims) {
|
||||
|
|
@ -294,7 +296,7 @@ TEST(ReductionOpTest, ReduceLogSumExp_default_axes_keepdims) {
|
|||
55.0f, 1.0f,
|
||||
60.0f, 2.0f});
|
||||
test.AddOutput<float>("reduced", {1, 1, 1}, {60.00671387f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceLogSumExp_do_not_keepdims) {
|
||||
|
|
@ -321,7 +323,7 @@ TEST(ReductionOpTest, ReduceLogSumExp_do_not_keepdims_2) {
|
|||
test.AddInput<float>("data", {3},
|
||||
{1.0f, 2.0f, 3.0f});
|
||||
test.AddOutput<float>("reduced", {}, {3.40760596f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceLogSumExp_keepdims) {
|
||||
|
|
@ -355,7 +357,7 @@ TEST(ReductionOpTest, ReduceLogSumExp) {
|
|||
9.0f, 10.0f,
|
||||
11.0f, 12.0f});
|
||||
test.AddOutput<float>("reduced", {1, 2, 1}, {10.33174133f, 12.33174133f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceLogSumExp_int32) {
|
||||
|
|
@ -372,7 +374,7 @@ TEST(ReductionOpTest, ReduceLogSumExp_int32) {
|
|||
9, 10,
|
||||
11, 12});
|
||||
test.AddOutput<int32_t>("reduced", {1, 2, 1}, {10, 12});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceMax_default_axes_keepdims) {
|
||||
|
|
@ -388,7 +390,7 @@ TEST(ReductionOpTest, ReduceMax_default_axes_keepdims) {
|
|||
55.0f, 1.0f,
|
||||
60.0f, 2.0f});
|
||||
test.AddOutput<float>("reduced", {1, 1, 1}, {60.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceMax_do_not_keepdims) {
|
||||
|
|
@ -405,7 +407,7 @@ TEST(ReductionOpTest, ReduceMax_do_not_keepdims) {
|
|||
55.0f, 1.0f,
|
||||
60.0f, 2.0f});
|
||||
test.AddOutput<float>("reduced", {3, 2}, {20.0f, 2.0f, 40.0f, 2.0f, 60.0f, 2.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceMax_do_not_keepdims_2) {
|
||||
|
|
@ -415,7 +417,7 @@ TEST(ReductionOpTest, ReduceMax_do_not_keepdims_2) {
|
|||
test.AddInput<float>("data", {3},
|
||||
{5.0f, 1.0f, 20.0f});
|
||||
test.AddOutput<float>("reduced", {}, {20.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceMax_keepdims) {
|
||||
|
|
@ -466,7 +468,7 @@ TEST(ReductionOpTest, ReduceMax_int32) {
|
|||
9, 10,
|
||||
11, 12});
|
||||
test.AddOutput<int32_t>("reduced", {3, 1, 1}, {4, 8, 12});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceMean_default_axes_keepdims) {
|
||||
|
|
@ -482,7 +484,7 @@ TEST(ReductionOpTest, ReduceMean_default_axes_keepdims) {
|
|||
55.0f, 1.0f,
|
||||
60.0f, 2.0f});
|
||||
test.AddOutput<float>("reduced", {1, 1, 1}, {18.25f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceMean_do_not_keepdims) {
|
||||
|
|
@ -509,7 +511,7 @@ TEST(ReductionOpTest, ReduceMean_do_not_keepdims_2) {
|
|||
test.AddInput<float>("data", {3},
|
||||
{1.0f, 2.0f, 3.0f});
|
||||
test.AddOutput<float>("reduced", {}, {2.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceMean_keepdims) {
|
||||
|
|
@ -543,7 +545,7 @@ TEST(ReductionOpTest, ReduceMean) {
|
|||
9.0f, 10.0f,
|
||||
11.0f, 12.0f});
|
||||
test.AddOutput<float>("reduced", {1, 2, 1}, {5.5f, 7.5f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceMean_int32) {
|
||||
|
|
@ -560,7 +562,7 @@ TEST(ReductionOpTest, ReduceMean_int32) {
|
|||
90, 100,
|
||||
110, 120});
|
||||
test.AddOutput<int32_t>("reduced", {1, 2, 1}, {55, 75});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceMin_default_axes_keepdims) {
|
||||
|
|
@ -576,7 +578,7 @@ TEST(ReductionOpTest, ReduceMin_default_axes_keepdims) {
|
|||
55.0f, 1.0f,
|
||||
60.0f, 2.0f});
|
||||
test.AddOutput<float>("reduced", {1, 1, 1}, {1.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceMin_do_not_keepdims) {
|
||||
|
|
@ -603,7 +605,7 @@ TEST(ReductionOpTest, ReduceMin_do_not_keepdims_2) {
|
|||
test.AddInput<float>("data", {3},
|
||||
{5.0f, 1.0f, 20.0f});
|
||||
test.AddOutput<float>("reduced", {}, {1.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceMin_keepdims) {
|
||||
|
|
@ -637,7 +639,7 @@ TEST(ReductionOpTest, ReduceMin) {
|
|||
9.0f, 10.0f,
|
||||
11.0f, 12.0f});
|
||||
test.AddOutput<float>("reduced", {1, 2, 1}, {1.0f, 3.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceMin_int32) {
|
||||
|
|
@ -654,7 +656,7 @@ TEST(ReductionOpTest, ReduceMin_int32) {
|
|||
9, 10,
|
||||
11, 12});
|
||||
test.AddOutput<int32_t>("reduced", {1, 2, 1}, {1, 3});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceSum) {
|
||||
|
|
@ -671,7 +673,7 @@ TEST(ReductionOpTest, ReduceSum) {
|
|||
9.0f, 10.0f,
|
||||
11.0f, 12.0f});
|
||||
test.AddOutput<float>("reduced", {1, 2, 1}, {33.0f, 45.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceSum_axes01) {
|
||||
|
|
@ -722,7 +724,7 @@ TEST(ReductionOpTest, ReduceSum_int32) {
|
|||
9, 10,
|
||||
11, 12});
|
||||
test.AddOutput<int32_t>("reduced", {1, 2, 1}, {33, 45});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceSum_default_axes_keepdims) {
|
||||
|
|
@ -738,7 +740,7 @@ TEST(ReductionOpTest, ReduceSum_default_axes_keepdims) {
|
|||
9.0f, 10.0f,
|
||||
11.0f, 12.0f});
|
||||
test.AddOutput<float>("reduced", {1, 1, 1}, {78.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceSum_do_not_keepdims) {
|
||||
|
|
@ -759,7 +761,7 @@ TEST(ReductionOpTest, ReduceSum_do_not_keepdims_2) {
|
|||
test.AddInput<float>("data", {3},
|
||||
{1.0f, 2.0f, 3.0f});
|
||||
test.AddOutput<float>("reduced", {}, {6.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceSum_keepdims) {
|
||||
|
|
@ -793,7 +795,7 @@ TEST(ReductionOpTest, ReduceSumSquare) {
|
|||
9.0f, 10.0f,
|
||||
11.0f, 12.0f});
|
||||
test.AddOutput<float>("reduced", {1, 2, 1}, {247.0f, 403.f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceSumSquare_int32) {
|
||||
|
|
@ -810,7 +812,7 @@ TEST(ReductionOpTest, ReduceSumSquare_int32) {
|
|||
9, 10,
|
||||
11, 12});
|
||||
test.AddOutput<int32_t>("reduced", {1, 2, 1}, {247, 403});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceSumSquare_default_axes_keepdims) {
|
||||
|
|
@ -826,7 +828,7 @@ TEST(ReductionOpTest, ReduceSumSquare_default_axes_keepdims) {
|
|||
9.0f, 10.0f,
|
||||
11.0f, 12.0f});
|
||||
test.AddOutput<float>("reduced", {1, 1, 1}, {650.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceSumSquare_do_not_keepdims) {
|
||||
|
|
@ -853,7 +855,7 @@ TEST(ReductionOpTest, ReduceSumSquare_do_not_keepdims_2) {
|
|||
test.AddInput<float>("data", {3},
|
||||
{1.0f, 2.0f, 3.0f});
|
||||
test.AddOutput<float>("reduced", {}, {14.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceSumSquare_keepdims) {
|
||||
|
|
@ -885,7 +887,7 @@ TEST(ReductionOpTest, ReduceProd_default_axes_keepdims) {
|
|||
9.0f, 10.0f,
|
||||
11.0f, 12.0f});
|
||||
test.AddOutput<float>("reduced", {1, 1, 1}, {479001600.f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceProd_do_not_keepdims) {
|
||||
|
|
@ -912,7 +914,7 @@ TEST(ReductionOpTest, ReduceProd_do_not_keepdims_2) {
|
|||
test.AddInput<float>("data", {3},
|
||||
{1.0f, 2.0f, 3.0f});
|
||||
test.AddOutput<float>("reduced", {}, {6.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceProd_keepdims) {
|
||||
|
|
@ -945,7 +947,7 @@ TEST(ReductionOpTest, ReduceProd) {
|
|||
9.0f, 10.0f,
|
||||
11.0f, 12.0f});
|
||||
test.AddOutput<float>("reduced", {1, 2, 1}, {5400.f, 88704.f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ReduceProd_int32) {
|
||||
|
|
@ -961,7 +963,7 @@ TEST(ReductionOpTest, ReduceProd_int32) {
|
|||
9, 10,
|
||||
11, 12});
|
||||
test.AddOutput<int32_t>("reduced", {1, 2, 1}, {5400, 88704});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ArgMax) {
|
||||
|
|
@ -981,7 +983,7 @@ TEST(ReductionOpTest, ArgMax) {
|
|||
{1, 1,
|
||||
1, 1,
|
||||
1, 1});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ArgMax_do_not_keepdims) {
|
||||
|
|
@ -1001,7 +1003,7 @@ TEST(ReductionOpTest, ArgMax_do_not_keepdims) {
|
|||
{1, 1,
|
||||
1, 1,
|
||||
1, 1});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ArgMax_do_not_keepdims_2) {
|
||||
|
|
@ -1012,7 +1014,7 @@ TEST(ReductionOpTest, ArgMax_do_not_keepdims_2) {
|
|||
{1.0f, 2.0f, 3.0f});
|
||||
test.AddOutput<int64_t>("reduced", {},
|
||||
{2});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ArgMax_int32) {
|
||||
|
|
@ -1032,7 +1034,7 @@ TEST(ReductionOpTest, ArgMax_int32) {
|
|||
{1, 1,
|
||||
1, 1,
|
||||
1, 1});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ArgMax2D) {
|
||||
|
|
@ -1045,7 +1047,7 @@ TEST(ReductionOpTest, ArgMax2D) {
|
|||
9.0f, 10.0f});
|
||||
test.AddOutput<int64_t>("reduced", {3, 1},
|
||||
{1, 0, 1});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ArgMin) {
|
||||
|
|
@ -1064,7 +1066,7 @@ TEST(ReductionOpTest, ArgMin) {
|
|||
test.AddOutput<int64_t>("reduced", {1, 2, 2},
|
||||
{0, 0,
|
||||
0, 0});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ArgMin_do_not_keepdims) {
|
||||
|
|
@ -1083,7 +1085,7 @@ TEST(ReductionOpTest, ArgMin_do_not_keepdims) {
|
|||
test.AddOutput<int64_t>("reduced", {2, 2},
|
||||
{0, 0,
|
||||
0, 0});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ArgMin_do_not_keepdims_2) {
|
||||
|
|
@ -1093,7 +1095,7 @@ TEST(ReductionOpTest, ArgMin_do_not_keepdims_2) {
|
|||
test.AddInput<float>("data", {3},
|
||||
{1.0f, 2.0f, 3.0f});
|
||||
test.AddOutput<int64_t>("reduced", {}, {0});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(ReductionOpTest, ArgMin_int32) {
|
||||
|
|
@ -1112,7 +1114,7 @@ TEST(ReductionOpTest, ArgMin_int32) {
|
|||
test.AddOutput<int64_t>("reduced", {2, 2},
|
||||
{0, 0,
|
||||
0, 0});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
namespace onnxruntime {
|
||||
namespace test {
|
||||
|
||||
// Disable TensorRT on some of the tests because the limit in its parser: axis >=0 && axis < nbDims
|
||||
|
||||
TEST(MathOpTest, Concat1D_string) {
|
||||
OpTester test("Concat");
|
||||
test.AddAttribute("axis", int64_t{0});
|
||||
|
|
@ -15,7 +17,7 @@ TEST(MathOpTest, Concat1D_string) {
|
|||
test.AddInput<std::string>("input2", {2}, {"2", "3"});
|
||||
test.AddInput<std::string>("input3", {4}, {"4", "5", "6", "7"});
|
||||
test.AddOutput<std::string>("concat_result", {7}, {"1", "2", "3", "4", "5", "6", "7"});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Concat1D_int32) {
|
||||
|
|
@ -26,7 +28,7 @@ TEST(MathOpTest, Concat1D_int32) {
|
|||
test.AddInput<int32_t>("input2", {2}, {2, 3});
|
||||
test.AddInput<int32_t>("input3", {4}, {4, 5, 6, 7});
|
||||
test.AddOutput<int32_t>("concat_result", {7}, {1, 2, 3, 4, 5, 6, 7});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Concat1D_int32_negative_axis) {
|
||||
|
|
@ -37,7 +39,7 @@ TEST(MathOpTest, Concat1D_int32_negative_axis) {
|
|||
test.AddInput<int32_t>("input2", {2}, {2, 3});
|
||||
test.AddInput<int32_t>("input3", {4}, {4, 5, 6, 7});
|
||||
test.AddOutput<int32_t>("concat_result", {7}, {1, 2, 3, 4, 5, 6, 7});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Concat1D_1) {
|
||||
|
|
@ -48,7 +50,7 @@ TEST(MathOpTest, Concat1D_1) {
|
|||
test.AddInput<float>("input2", {2}, {2.0f, 3.0f});
|
||||
test.AddInput<float>("input3", {4}, {4.0f, 5.0f, 6.0f, 7.0f});
|
||||
test.AddOutput<float>("concat_result", {7}, {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Concat1D_2) {
|
||||
|
|
@ -59,7 +61,7 @@ TEST(MathOpTest, Concat1D_2) {
|
|||
test.AddInput<float>("input2", {2}, {2.0f, 3.0f});
|
||||
test.AddInput<float>("input3", {0}, {});
|
||||
test.AddOutput<float>("concat_result", {3}, {1.0f, 2.0f, 3.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Concat2D_1) {
|
||||
|
|
@ -74,7 +76,7 @@ TEST(MathOpTest, Concat2D_1) {
|
|||
{11.0f, 12.0f, 13.0f, 14.0f,
|
||||
21.0f, 22.0f, 23.0f, 24.0f,
|
||||
31.0f, 32.0f, 33.0f, 34.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Concat2D_2) {
|
||||
|
|
@ -90,7 +92,7 @@ TEST(MathOpTest, Concat2D_2) {
|
|||
21.0f, 22.0f, 23.0f, 24.0f,
|
||||
31.0f, 32.0f, 33.0f, 34.0f,
|
||||
41.0f, 42.0f, 43.0f, 44.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Concat2D_3) {
|
||||
|
|
@ -101,7 +103,7 @@ TEST(MathOpTest, Concat2D_3) {
|
|||
test.AddInput<float>("input2", {1, 0}, {});
|
||||
test.AddInput<float>("input3", {1, 0}, {});
|
||||
test.AddOutput<float>("concat_result", {1, 0}, {});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Concat3D_1) {
|
||||
|
|
@ -133,7 +135,7 @@ TEST(MathOpTest, Concat3D_1) {
|
|||
311.0f, 312.0f, 313.0f,
|
||||
321.0f, 322.0f, 323.0f,
|
||||
331.0f, 332.0f, 333.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Concat3D_1_negative_axis) {
|
||||
|
|
@ -165,7 +167,7 @@ TEST(MathOpTest, Concat3D_1_negative_axis) {
|
|||
311.0f, 312.0f, 313.0f,
|
||||
321.0f, 322.0f, 323.0f,
|
||||
331.0f, 332.0f, 333.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Concat3D_2) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
namespace onnxruntime {
|
||||
namespace test {
|
||||
|
||||
// Disable TensorRT on some of the tests because of unsupported data types
|
||||
|
||||
TEST(GatherOpTest, Gather_axis0) {
|
||||
OpTester test("Gather");
|
||||
test.AddAttribute<int64_t>("axis", 0LL);
|
||||
|
|
@ -22,7 +24,7 @@ TEST(GatherOpTest, Gather_axis0) {
|
|||
{10.0f, 10.1f, 10.2f, 10.3f,
|
||||
11.0f, 11.1f, 11.2f, 11.3f,
|
||||
12.0f, 12.1f, 12.2f, 12.3f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GatherOpTest, Gather_negative_axis) {
|
||||
|
|
@ -40,7 +42,7 @@ TEST(GatherOpTest, Gather_negative_axis) {
|
|||
{10.0f, 10.1f, 10.2f, 10.3f,
|
||||
11.0f, 11.1f, 11.2f, 11.3f,
|
||||
12.0f, 12.1f, 12.2f, 12.3f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GatherOpTest, Gather_invalid_axis) {
|
||||
|
|
@ -92,7 +94,7 @@ TEST(GatherOpTest, Gather_invalid_index_gpu) {
|
|||
0.0f, 0.0f, 0.0f, 0.0f});
|
||||
|
||||
//On GPU, just set the value to 0 instead of report error. exclude all other providers
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kCpuExecutionProvider, kMklDnnExecutionProvider, kNupharExecutionProvider});
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kCpuExecutionProvider, kMklDnnExecutionProvider, kNupharExecutionProvider, kTensorrtExecutionProvider});
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -112,7 +114,7 @@ TEST(GatherOpTest, Gather_axis1) {
|
|||
0.0f, 0.1f, 0.2f, 0.3f,
|
||||
12.0f, 12.1f, 12.2f, 12.3f,
|
||||
10.0f, 10.1f, 10.2f, 10.3f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GatherOpTest, Gather_axis2) {
|
||||
|
|
@ -133,7 +135,7 @@ TEST(GatherOpTest, Gather_axis2) {
|
|||
10.1f, 10.0f, 10.2f,
|
||||
11.1f, 11.0f, 11.2f,
|
||||
12.1f, 12.0f, 12.2f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GatherOpTest, Gather_axis0_indices2d) {
|
||||
|
|
@ -149,7 +151,7 @@ TEST(GatherOpTest, Gather_axis0_indices2d) {
|
|||
test.AddOutput<float>("output", {2, 2, 3},
|
||||
{1.0f, 1.1f, 1.2f, 0.0f, 0.1f, 0.2f,
|
||||
2.0f, 2.1f, 2.2f, 1.0f, 1.1f, 1.2f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GatherOpTest, Gather_axis1_indices2d) {
|
||||
|
|
@ -166,7 +168,7 @@ TEST(GatherOpTest, Gather_axis1_indices2d) {
|
|||
{0.1f, 0.0f, 0.2f, 0.1f,
|
||||
1.1f, 1.0f, 1.2f, 1.1f,
|
||||
2.1f, 2.0f, 2.2f, 2.1f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GatherOpTest, Gather_axis1_indices2d_int32) {
|
||||
|
|
@ -183,7 +185,7 @@ TEST(GatherOpTest, Gather_axis1_indices2d_int32) {
|
|||
{1, 0, 2, 1,
|
||||
11, 10, 12, 11,
|
||||
21, 20, 22, 21});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GatherOpTest, Gather_axis1_indices2d_uint32) {
|
||||
|
|
@ -200,7 +202,7 @@ TEST(GatherOpTest, Gather_axis1_indices2d_uint32) {
|
|||
{1, 0, 2, 1,
|
||||
11, 10, 12, 11,
|
||||
21, 20, 22, 21});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GatherOpTest, Gather_axis1_indices2d_int16) {
|
||||
|
|
@ -217,7 +219,7 @@ TEST(GatherOpTest, Gather_axis1_indices2d_int16) {
|
|||
{1, 0, 2, 1,
|
||||
11, 10, 12, 11,
|
||||
21, 20, 22, 21});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GatherOpTest, Gather_axis1_indices2d_uint16) {
|
||||
|
|
@ -234,7 +236,7 @@ TEST(GatherOpTest, Gather_axis1_indices2d_uint16) {
|
|||
{1, 0, 2, 1,
|
||||
11, 10, 12, 11,
|
||||
21, 20, 22, 21});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GatherOpTest, Gather_axis1_indices2d_int8) {
|
||||
|
|
@ -251,7 +253,7 @@ TEST(GatherOpTest, Gather_axis1_indices2d_int8) {
|
|||
{1, 0, 2, 1,
|
||||
11, 10, 12, 11,
|
||||
21, 20, 22, 21});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GatherOpTest, Gather_axis1_indices2d_string) {
|
||||
|
|
@ -268,7 +270,7 @@ TEST(GatherOpTest, Gather_axis1_indices2d_string) {
|
|||
{"1", "0", "2", "1",
|
||||
"11", "10", "12", "11",
|
||||
"21", "20", "22", "21"});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GatherOpTest, Gather_axis1_indices2d_bool) {
|
||||
|
|
@ -285,7 +287,7 @@ TEST(GatherOpTest, Gather_axis1_indices2d_bool) {
|
|||
{false, true, true, false,
|
||||
true, true, false, true,
|
||||
true, false, false, true});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(GatherOpTest, Gather_perf) {
|
||||
|
|
@ -300,7 +302,7 @@ TEST(GatherOpTest, Gather_perf) {
|
|||
test.AddInput<int32_t>("data", {50000, 100}, input);
|
||||
test.AddInput<int32_t>("indices", {800, 1}, indices);
|
||||
test.AddOutput<int32_t>("output", {800, 1, 100}, output);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
} // namespace test
|
||||
} // namespace onnxruntime
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ TEST(Identity, StringType) {
|
|||
std::vector<int64_t> dims{2, 2};
|
||||
test.AddInput<std::string>("X", dims, {"a" , "b", "x", "y"});
|
||||
test.AddOutput<std::string>("Y", dims, {"a" , "b", "x", "y"});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT: unsupported data type
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
namespace onnxruntime {
|
||||
namespace test {
|
||||
|
||||
// Disable TensorRT on some of the tests because only constant mode and value 0 is supported for "Pad" node
|
||||
|
||||
TEST(TensorOpTest, Pad_Spec_Example) {
|
||||
OpTester test("Pad");
|
||||
|
||||
|
|
@ -14,7 +16,7 @@ TEST(TensorOpTest, Pad_Spec_Example) {
|
|||
test.AddAttribute("value", 0.0f);
|
||||
test.AddInput<float>("data", {3, 2}, {1.0f, 1.2f, 2.3f, 3.4f, 4.5f, 5.7f});
|
||||
test.AddOutput<float>("output", {3, 4}, {0.0f, 0.0f, 1.0f, 1.2f, 0.0f, 0.0f, 2.3f, 3.4f, 0.0f, 0.0f, 4.5f, 5.7f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, Pad_Constant_1D) {
|
||||
|
|
@ -24,7 +26,7 @@ TEST(TensorOpTest, Pad_Constant_1D) {
|
|||
test.AddAttribute("value", 1234.0f);
|
||||
test.AddInput<float>("data", {2}, {1.0f, 2.0f});
|
||||
test.AddOutput<float>("output", {5}, {1234.0f, 1.0f, 2.0f, 1234.0f, 1234.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, Pad_Constant_1D_Zero) {
|
||||
|
|
@ -34,7 +36,7 @@ TEST(TensorOpTest, Pad_Constant_1D_Zero) {
|
|||
test.AddAttribute("value", 1234.0f);
|
||||
test.AddInput<float>("data", {2}, {1.0f, 2.0f});
|
||||
test.AddOutput<float>("output", {2}, {1.0f, 2.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, Pad_Constant_2D) {
|
||||
|
|
@ -50,7 +52,7 @@ TEST(TensorOpTest, Pad_Constant_2D) {
|
|||
1234.0f, 1234.0f, 11.0f, 21.0f, 1234.0f, 1234.0f,
|
||||
1234.0f, 1234.0f, 12.0f, 22.0f, 1234.0f, 1234.0f,
|
||||
1234.0f, 1234.0f, 1234.0f, 1234.0f, 1234.0f, 1234.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, Pad_Constant_2D_negative) {
|
||||
|
|
@ -66,7 +68,7 @@ TEST(TensorOpTest, Pad_Constant_2D_negative) {
|
|||
1234.0f, 1234.0f, 11.0f, 21.0f,
|
||||
1234.0f, 1234.0f, 12.0f, 22.0f,
|
||||
1234.0f, 1234.0f, 1234.0f, 1234.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, Pad_3D_complex) {
|
||||
|
|
@ -86,7 +88,7 @@ TEST(TensorOpTest, Pad_3D_complex) {
|
|||
|
||||
111.0f, 112.0f,
|
||||
121.0f, 122.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, Pad_Edge_2D) {
|
||||
|
|
@ -104,7 +106,7 @@ TEST(TensorOpTest, Pad_Edge_2D) {
|
|||
12.0f, 12.0f, 12.0f, 22.0f, 32.0f, 32.0f, 32.0f,
|
||||
12.0f, 12.0f, 12.0f, 22.0f, 32.0f, 32.0f, 32.0f,
|
||||
12.0f, 12.0f, 12.0f, 22.0f, 32.0f, 32.0f, 32.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, Pad_Edge_3D) {
|
||||
|
|
@ -137,7 +139,7 @@ TEST(TensorOpTest, Pad_Edge_3D) {
|
|||
12.0f, 12.0f, 12.0f, 22.0f, 32.0f, 32.0f, 32.0f,
|
||||
12.0f, 12.0f, 12.0f, 22.0f, 32.0f, 32.0f, 32.0f});
|
||||
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, Pad_Reflect_2D) {
|
||||
|
|
@ -157,7 +159,7 @@ TEST(TensorOpTest, Pad_Reflect_2D) {
|
|||
33.0f, 23.0f, 13.0f, 23.0f, 33.0f, 23.0f, 13.0f,
|
||||
32.0f, 22.0f, 12.0f, 22.0f, 32.0f, 22.0f, 12.0f,
|
||||
31.0f, 21.0f, 11.0f, 21.0f, 31.0f, 21.0f, 11.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ void TestShape(const std::initializer_list<T>& data, const std::vector<int64_t>&
|
|||
OpTester test("Shape");
|
||||
test.AddInput<T>("data", shape, data);
|
||||
test.AddOutput<int64_t>("output", {static_cast<int64_t>(shape.size())}, shape);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT parser: unsupported data types
|
||||
}
|
||||
|
||||
TEST(ShapeOpTest, ShapeTestBool) { TestShape <bool> ({true, true, false, false, true, false}, {2, 3}); }
|
||||
|
|
@ -26,4 +26,4 @@ TEST(ShapeOpTest, ShapeTestUint32) { TestShape <uint32_t> ({1, 2, 3, 4, 5, 6, 7,
|
|||
TEST(ShapeOpTest, ShapeTestUint64) { TestShape <uint64_t> ({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, {1, 12}); }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ void TestSizeOp(const std::initializer_list<int64_t>& dims) {
|
|||
std::vector<int64_t> scalar_dims;
|
||||
test.AddOutput<int64_t>("B", scalar_dims, {actual_size});
|
||||
|
||||
test.Run();
|
||||
//Run tests. Disable TensorRT EP because of dynamic shape or unsupported data types
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
// Single-dimensional float tensor
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
namespace onnxruntime {
|
||||
namespace test {
|
||||
|
||||
// Disable TensorRT on the tests because axis=0 is not supported
|
||||
|
||||
template <typename T>
|
||||
void RunSliceTest(const std::vector<int64_t>& input_dims,
|
||||
const std::vector<T>& input_vals,
|
||||
|
|
@ -27,7 +29,7 @@ void RunSliceTest(const std::vector<int64_t>& input_dims,
|
|||
testv9.AddAttribute("axes", axes);
|
||||
testv9.AddInput<T>("data", input_dims, input_vals);
|
||||
testv9.AddOutput<T>("output", output_dims, output_vals);
|
||||
testv9.Run();
|
||||
testv9.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
// V10
|
||||
|
|
@ -40,7 +42,7 @@ void RunSliceTest(const std::vector<int64_t>& input_dims,
|
|||
if (steps.size() != 0)
|
||||
testv10.AddInput<int64_t>("steps", {static_cast<int64_t>(steps.size())}, steps);
|
||||
testv10.AddOutput<T>("output", output_dims, output_vals);
|
||||
testv10.Run();
|
||||
testv10.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
// Slice V1-9 & Slice V10 can both run the following tests
|
||||
|
|
@ -369,7 +371,7 @@ TEST(SliceTest, Slice3D_WithPositiveSteps_AllAxes) {
|
|||
{2, 1, 1},
|
||||
{26, 9},
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(SliceTest, Slice3D_WithPositiveAndNegativeSteps_SubsetOfAxes_1) {
|
||||
RunSliceTest<int32_t>({3, 3, 3},
|
||||
|
|
@ -416,8 +418,8 @@ TEST(SliceTest, Slice3D_WithPositiveAndNegativeSteps_SubsetOfAxes_2) {
|
|||
}
|
||||
|
||||
// Slice for Reversing
|
||||
// With numeric_limit_max, it means slice to the end of a dimension
|
||||
// (whichever direction we are stepping)
|
||||
// With numeric_limit_max, it means slice to the end of a dimension
|
||||
// (whichever direction we are stepping)
|
||||
TEST(SliceTest, Slice1D_ReverseAllAxes_1) {
|
||||
RunSliceTest<float>({4},
|
||||
{1.0f, 2.0f, 3.0f, 4.0f},
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ using ShapeAndInt32Data = ShapeAndData<int32_t>;
|
|||
using ExpectResult = OpTester::ExpectResult;
|
||||
|
||||
template<typename T> void RunTest(int64_t axis, const std::vector<int64_t> split_sizes, const ShapeAndData<T>& input,
|
||||
const std::vector<ShapeAndData<T>>& outputs,
|
||||
const std::vector<ShapeAndData<T>>& outputs, bool is_tensorrt_supported = true,
|
||||
bool expect_failure = false, const std::string& err_msg = {}) {
|
||||
OpTester test("Split");
|
||||
|
||||
|
|
@ -33,8 +33,11 @@ template<typename T> void RunTest(int64_t axis, const std::vector<int64_t> split
|
|||
oss << "output" << i++;
|
||||
test.AddOutput<T>(oss.str().c_str(), shape, data);
|
||||
}
|
||||
|
||||
test.Run(expect_failure ? ExpectResult::kExpectFailure : ExpectResult::kExpectSuccess, err_msg);
|
||||
std::unordered_set<std::string> excluded_providers;
|
||||
if (!is_tensorrt_supported) {
|
||||
excluded_providers.insert(kTensorrtExecutionProvider);
|
||||
}
|
||||
test.Run(expect_failure ? ExpectResult::kExpectFailure : ExpectResult::kExpectSuccess, err_msg, excluded_providers);
|
||||
}
|
||||
|
||||
TEST(SplitOperatorTest, Axis0EqualSplit) {
|
||||
|
|
@ -56,7 +59,7 @@ TEST(SplitOperatorTest, Axis0EqualSplit) {
|
|||
{5.f, 6.f,
|
||||
7.f, 8.f}});
|
||||
|
||||
RunTest<float>(axis, {}, input, outputs);
|
||||
RunTest<float>(axis, {}, input, outputs, false);//TensorRT parser: Assertion failed: axis != BATCH_DIM
|
||||
}
|
||||
|
||||
TEST(SplitOperatorTest, Axis0EqualSplitInt32) {
|
||||
|
|
@ -78,7 +81,7 @@ TEST(SplitOperatorTest, Axis0EqualSplitInt32) {
|
|||
{5, 6,
|
||||
7, 8}});
|
||||
|
||||
RunTest<int32_t>(axis, {}, input, outputs);
|
||||
RunTest<int32_t>(axis, {}, input, outputs, false);//TensorRT parser: Assertion failed: axis != BATCH_DIM
|
||||
}
|
||||
|
||||
TEST(SplitOperatorTest, Axis0UnequalSplit) {
|
||||
|
|
@ -101,7 +104,7 @@ TEST(SplitOperatorTest, Axis0UnequalSplit) {
|
|||
5.f, 6.f,
|
||||
7.f, 8.f}});
|
||||
|
||||
RunTest<float>(axis, splits, input, outputs);
|
||||
RunTest<float>(axis, splits, input, outputs, false);//TensorRT parser: Assertion failed: axis != BATCH_DIM
|
||||
}
|
||||
|
||||
TEST(SplitOperatorTest, Axis1EqualSplit) {
|
||||
|
|
@ -121,7 +124,7 @@ TEST(SplitOperatorTest, Axis1EqualSplit) {
|
|||
{3.f, 4.f,
|
||||
7.f, 8.f}});
|
||||
|
||||
RunTest<float>(axis, {}, input, outputs);
|
||||
RunTest<float>(axis, {}, input, outputs, false);
|
||||
}
|
||||
|
||||
TEST(SplitOperatorTest, Axis1UnequalSplit) {
|
||||
|
|
@ -143,7 +146,7 @@ TEST(SplitOperatorTest, Axis1UnequalSplit) {
|
|||
{4.f,
|
||||
8.f}});
|
||||
|
||||
RunTest<float>(axis, splits, input, outputs);
|
||||
RunTest<float>(axis, splits, input, outputs, false);
|
||||
}
|
||||
|
||||
ShapeAndFloatData CreateInput(std::vector<int64_t> shape) {
|
||||
|
|
@ -186,7 +189,7 @@ TEST(SplitOperatorTest, Axis2EqualSplit) {
|
|||
17.f, 18.f,
|
||||
23.f, 24.f}});
|
||||
|
||||
RunTest<float>(axis, {}, input, outputs);
|
||||
RunTest<float>(axis, {}, input, outputs, false);
|
||||
}
|
||||
|
||||
TEST(SplitOperatorTest, Axis2UnequalSplit) {
|
||||
|
|
@ -218,7 +221,7 @@ TEST(SplitOperatorTest, Axis2UnequalSplit) {
|
|||
16.f, 17.f, 18.f,
|
||||
22.f, 23.f, 24.f}});
|
||||
|
||||
RunTest<float>(axis, splits, input, outputs);
|
||||
RunTest<float>(axis, splits, input, outputs, false);
|
||||
}
|
||||
|
||||
// test a split of a dimension that has leading and trailing dimensions
|
||||
|
|
@ -242,7 +245,7 @@ TEST(SplitOperatorTest, Axis1SplitMiddleDimensionEqually) {
|
|||
25.f, 26.f, 27.f, 28.f,
|
||||
29.f, 30.f, 31.f, 32.f}});
|
||||
|
||||
RunTest<float>(axis, {}, input, outputs);
|
||||
RunTest<float>(axis, {}, input, outputs, false);
|
||||
}
|
||||
|
||||
// test a split of a dimension that has leading and trailing dimensions
|
||||
|
|
@ -268,7 +271,7 @@ TEST(SplitOperatorTest, Axis1SplitMiddleDimensionUnequally) {
|
|||
25.f, 26.f, 27.f, 28.f,
|
||||
29.f, 30.f, 31.f, 32.f}});
|
||||
|
||||
RunTest<float>(axis, splits, input, outputs);
|
||||
RunTest<float>(axis, splits, input, outputs, false);
|
||||
}
|
||||
|
||||
TEST(SplitOperatorTest, NegativeAxis) {
|
||||
|
|
@ -288,7 +291,7 @@ TEST(SplitOperatorTest, NegativeAxis) {
|
|||
{3.f, 4.f,
|
||||
7.f, 8.f}});
|
||||
|
||||
RunTest<float>(axis, {}, input, outputs);
|
||||
RunTest<float>(axis, {}, input, outputs, false);
|
||||
}
|
||||
|
||||
TEST(SplitOperatorTest, InvalidAxis) {
|
||||
|
|
@ -304,7 +307,7 @@ TEST(SplitOperatorTest, InvalidAxis) {
|
|||
|
||||
outputs.push_back({{1}, {0.f}});
|
||||
|
||||
RunTest<float>(axis, {}, input, outputs, true, "Invalid value of attribute 'axis'");
|
||||
RunTest<float>(axis, {}, input, outputs, true, true, "Invalid value of attribute 'axis'");
|
||||
}
|
||||
|
||||
// sum of values in splits is too small
|
||||
|
|
@ -324,7 +327,7 @@ TEST(SplitOperatorTest, SplitAttributeSumTooSmall) {
|
|||
outputs.push_back({{1, 2}, {1.f, 2.f}});
|
||||
outputs.push_back({{2, 2}, {3.f, 4.f, 5.f, 6.f}});
|
||||
|
||||
RunTest<float>(axis, splits, input, outputs, true, "Cannot split using values in 'split' attribute");
|
||||
RunTest<float>(axis, splits, input, outputs, false, true, "Cannot split using values in 'split' attribute");//TensorRT parser: Assertion failed: axis != BATCH_DIM
|
||||
}
|
||||
|
||||
TEST(SplitOperatorTest, InvalidValueInSplitAttribute) {
|
||||
|
|
@ -342,7 +345,7 @@ TEST(SplitOperatorTest, InvalidValueInSplitAttribute) {
|
|||
outputs.push_back({{1, 2}, {1.f, 2.f}});
|
||||
outputs.push_back({{3, 2}, {3.f, 4.f, 5.f, 6.f, 7.f, 8.f}});
|
||||
|
||||
RunTest<float>(axis, splits, input, outputs, true, "Invalid value in 'split' attribute");
|
||||
RunTest<float>(axis, splits, input, outputs, false, true, "Invalid value in 'split' attribute");//TensorRT parser: Assertion failed: axis != BATCH_DIM
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -7,12 +7,14 @@
|
|||
namespace onnxruntime {
|
||||
namespace test {
|
||||
|
||||
// Disable TensorRT on the tests because axis=0 is not supported
|
||||
|
||||
TEST(SqueezeOpTest, Squeeze_1) {
|
||||
OpTester test("Squeeze");
|
||||
test.AddAttribute("axes", std::vector<int64_t>{0});
|
||||
test.AddInput<float>("data", {1, 3, 4, 5}, std::vector<float>(60, 1.0f));
|
||||
test.AddOutput<float>("squeezed", {3, 4, 5}, std::vector<float>(60, 1.0f));
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(SqueezeOpTest, Squeeze_1_int32) {
|
||||
|
|
@ -20,7 +22,7 @@ TEST(SqueezeOpTest, Squeeze_1_int32) {
|
|||
test.AddAttribute("axes", std::vector<int64_t>{0});
|
||||
test.AddInput<int32_t>("data", {1, 3, 4, 5}, std::vector<int32_t>(60, 1));
|
||||
test.AddOutput<int32_t>("squeezed", {3, 4, 5}, std::vector<int32_t>(60, 1));
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(SqueezeOpTest, Squeeze_string) {
|
||||
|
|
@ -28,7 +30,7 @@ TEST(SqueezeOpTest, Squeeze_string) {
|
|||
test.AddAttribute("axes", std::vector<int64_t>{0, 2, 4});
|
||||
test.AddInput<std::string>("data", {1, 2, 1, 3, 1}, std::vector<std::string>({"1", "2", "3", "4", "5", "6"}));
|
||||
test.AddOutput<std::string>("squeezed", {2, 3}, std::vector<std::string>({"1", "2", "3", "4", "5", "6"}));
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(SqueezeOpTest, Squeeze_2) {
|
||||
|
|
@ -38,7 +40,7 @@ TEST(SqueezeOpTest, Squeeze_2) {
|
|||
std::vector<float>{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f});
|
||||
test.AddOutput<float>("squeezed", {4, 2},
|
||||
std::vector<float>{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(SqueezeOpTest, UnsortedAxes) {
|
||||
|
|
@ -49,7 +51,7 @@ TEST(SqueezeOpTest, UnsortedAxes) {
|
|||
std::vector<float>{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f});
|
||||
test.AddOutput<float>("squeezed", {4, 2},
|
||||
std::vector<float>{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(SqueezeOpTest, DuplicateAxes) {
|
||||
|
|
@ -60,7 +62,7 @@ TEST(SqueezeOpTest, DuplicateAxes) {
|
|||
std::vector<float>{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f});
|
||||
test.AddOutput<float>("squeezed", {4, 2},
|
||||
std::vector<float>{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(SqueezeOpTest, BadAxes) {
|
||||
|
|
@ -72,7 +74,7 @@ TEST(SqueezeOpTest, BadAxes) {
|
|||
test.AddOutput<float>("squeezed", {3, 4, 5}, std::vector<float>(60, 1.0f));
|
||||
|
||||
// Expect failure.
|
||||
test.Run(OpTester::ExpectResult::kExpectFailure, "Dimension of input 0 must be 1 instead of 3");
|
||||
test.Run(OpTester::ExpectResult::kExpectFailure, "Dimension of input 0 must be 1 instead of 3", {kTensorrtExecutionProvider});
|
||||
}
|
||||
} // namespace test
|
||||
} // namespace onnxruntime
|
||||
|
|
|
|||
|
|
@ -12,13 +12,15 @@ namespace test {
|
|||
|
||||
using ExpectResult = OpTester::ExpectResult;
|
||||
|
||||
// Disable TensorRT on some of the tests because of unsupported data types
|
||||
|
||||
TEST(TensorOpTest, Reshape) {
|
||||
OpTester test("Reshape");
|
||||
|
||||
test.AddInput<float>("data", {2, 3}, std::vector<float>(6, 1.0f));
|
||||
test.AddInput<int64_t>("shape", {3}, {-1, 0, 2});
|
||||
test.AddOutput<float>("reshaped", {1, 3, 2}, std::vector<float>(6, 1.0f));
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kNupharExecutionProvider}); // Nuphar only supports reshape shape from initializer
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kNupharExecutionProvider, kTensorrtExecutionProvider}); // Nuphar only supports reshape shape from initializer
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, ReshapeWithEmptyDim) {
|
||||
|
|
@ -27,7 +29,7 @@ TEST(TensorOpTest, ReshapeWithEmptyDim) {
|
|||
test.AddInput<float>("data", {1, 1, 1}, std::vector<float>(1, 1.0f));
|
||||
test.AddInput<int64_t>("shape", {0}, {}, true);
|
||||
test.AddOutput<float>("reshaped", {}, std::vector<float>(1, 1.0f));
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, ReshapeWithInitializer) {
|
||||
|
|
@ -36,7 +38,7 @@ TEST(TensorOpTest, ReshapeWithInitializer) {
|
|||
test.AddInput<float>("data", {2, 3}, std::vector<float>(6, 1.0f));
|
||||
test.AddInput<int64_t>("shape", {3}, {-1, 0, 2}, true);
|
||||
test.AddOutput<float>("reshaped", {1, 3, 2}, std::vector<float>(6, 1.0f));
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, Identity) {
|
||||
|
|
@ -52,7 +54,7 @@ TEST(TensorOpTest, IdentityString) {
|
|||
std::vector<std::string> X{"this", "is", "a", "test", "for", "identity"};
|
||||
test.AddInput<std::string>("input", {2, 3}, X);
|
||||
test.AddOutput<std::string>("output", {2, 3}, X);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, ShapeTest2D) {
|
||||
|
|
@ -60,7 +62,7 @@ TEST(TensorOpTest, ShapeTest2D) {
|
|||
|
||||
test.AddInput<float>("data", {2, 3}, std::vector<float>(6, 1.0f));
|
||||
test.AddOutput<int64_t>("shape", {2}, {2, 3});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, ShapeTest3D) {
|
||||
|
|
@ -68,7 +70,7 @@ TEST(TensorOpTest, ShapeTest3D) {
|
|||
|
||||
test.AddInput<float>("data", {2, 3, 4}, std::vector<float>(24, 1.0f));
|
||||
test.AddOutput<int64_t>("shape", {3}, {2, 3, 4});
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
template <typename SrcType,
|
||||
|
|
@ -83,7 +85,7 @@ void TestCastOp(const std::initializer_list<SrcType>& input,
|
|||
test.AddAttribute("to", toType);
|
||||
test.AddInput<SrcType>("input", dimensions, input);
|
||||
test.AddOutput<DstType>("output", dimensions, output);
|
||||
test.Run(expect_result, expected_failure_string);
|
||||
test.Run(expect_result, expected_failure_string, {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
template <typename SrcType>
|
||||
|
|
@ -512,7 +514,7 @@ TEST(TensorOpTest, MeanVarianceNormalizationCPUTest_Version1_TO_8) {
|
|||
MeanVarianceNormalizationPerChannel(false, false);
|
||||
|
||||
// across_channels: false, normalize_variance: true
|
||||
MeanVarianceNormalizationPerChannel(false, true);
|
||||
MeanVarianceNormalizationPerChannel(false, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -603,7 +605,7 @@ void MeanVarianceNormalizationFunctionAcrossChannels(std::vector<int64_t> axes)
|
|||
}
|
||||
|
||||
TEST(TensorOpTest, MeanVarianceNormalizationCPUTest) {
|
||||
|
||||
|
||||
// axes: {0, 1, 2, 3} for across_channels
|
||||
MeanVarianceNormalizationFunctionAcrossChannels({0, 1, 2, 3});
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
namespace onnxruntime {
|
||||
namespace test {
|
||||
|
||||
// Disable TensorRT on the tests because of errors in the parser
|
||||
|
||||
template <class T>
|
||||
void TransposeTest(std::vector<int64_t>& input_shape,
|
||||
std::vector<T>& input_vals,
|
||||
|
|
@ -18,7 +20,7 @@ void TransposeTest(std::vector<int64_t>& input_shape,
|
|||
test.AddAttribute("perm", *p_perm);
|
||||
test.AddInput<T>("X", input_shape, input_vals);
|
||||
test.AddOutput<T>("Y", expected_shape, expected_vals);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
// Test 2 dimensional transpose, with no permutation attribute specified
|
||||
|
|
|
|||
|
|
@ -7,13 +7,15 @@
|
|||
namespace onnxruntime {
|
||||
namespace test {
|
||||
|
||||
// Disable TensorRT on the tests because of errors in the parser
|
||||
|
||||
TEST(TensorOpTest, Unsqueeze_1) {
|
||||
OpTester test("Unsqueeze");
|
||||
|
||||
test.AddAttribute("axes", std::vector<int64_t>{1});
|
||||
test.AddInput<float>("input", {2, 3, 4}, std::vector<float>(2 * 3 * 4, 1.0f));
|
||||
test.AddOutput<float>("output", {2, 1, 3, 4}, std::vector<float>(2 * 3 * 4, 1.0f));
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, Unsqueeze_1_int32) {
|
||||
|
|
@ -22,7 +24,7 @@ TEST(TensorOpTest, Unsqueeze_1_int32) {
|
|||
test.AddAttribute("axes", std::vector<int64_t>{1});
|
||||
test.AddInput<int32_t>("input", {2, 3, 4}, std::vector<int32_t>(2 * 3 * 4, 1));
|
||||
test.AddOutput<int32_t>("output", {2, 1, 3, 4}, std::vector<int32_t>(2 * 3 * 4, 1));
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, Unsqueeze_2) {
|
||||
|
|
@ -31,7 +33,7 @@ TEST(TensorOpTest, Unsqueeze_2) {
|
|||
test.AddAttribute("axes", std::vector<int64_t>{0, 4});
|
||||
test.AddInput<float>("input", {2, 3, 4}, std::vector<float>(2 * 3 * 4, 1.0f));
|
||||
test.AddOutput<float>("output", {1, 2, 3, 4, 1}, std::vector<float>(2 * 3 * 4, 1.0f));
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, Unsqueeze_3) {
|
||||
|
|
@ -40,7 +42,7 @@ TEST(TensorOpTest, Unsqueeze_3) {
|
|||
test.AddAttribute("axes", std::vector<int64_t>{2, 1, 0});
|
||||
test.AddInput<float>("input", {2, 3, 4}, std::vector<float>(2 * 3 * 4, 1.0f));
|
||||
test.AddOutput<float>("output", {1, 1, 1, 2, 3, 4}, std::vector<float>(2 * 3 * 4, 1.0f));
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, Unsqueeze_Duplicate) {
|
||||
|
|
@ -49,7 +51,7 @@ TEST(TensorOpTest, Unsqueeze_Duplicate) {
|
|||
test.AddAttribute("axes", std::vector<int64_t>{2, 1, 0, 2});
|
||||
test.AddInput<float>("input", {2, 3, 4}, std::vector<float>(2 * 3 * 4, 1.0f));
|
||||
test.AddOutput<float>("output", {1, 1, 1, 2, 3, 4}, std::vector<float>(2 * 3 * 4, 1.0f));
|
||||
test.Run(OpTester::ExpectResult::kExpectFailure, "'axes' has a duplicate axis");
|
||||
test.Run(OpTester::ExpectResult::kExpectFailure, "'axes' has a duplicate axis", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(TensorOpTest, Unsqueeze_OutOfRange) {
|
||||
|
|
@ -58,7 +60,7 @@ TEST(TensorOpTest, Unsqueeze_OutOfRange) {
|
|||
test.AddAttribute("axes", std::vector<int64_t>{4});
|
||||
test.AddInput<float>("input", {2, 3, 4}, std::vector<float>(2 * 3 * 4, 1.0f));
|
||||
test.AddOutput<float>("output", {2, 1, 3, 4}, std::vector<float>(2 * 3 * 4, 1.0f));
|
||||
test.Run(OpTester::ExpectResult::kExpectFailure, "Mismatch between number of source and target dimensions.");
|
||||
test.Run(OpTester::ExpectResult::kExpectFailure, "Mismatch between number of source and target dimensions.", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
namespace onnxruntime {
|
||||
namespace test {
|
||||
|
||||
// Disable TensorRT on some of the tests because TensorRT only supports "nearest" mode Upsample and limited data types
|
||||
|
||||
TEST(UpsampleOpTest, UpsampleOpNearestTest) {
|
||||
OpTester test("Upsample");
|
||||
|
||||
|
|
@ -67,7 +69,7 @@ TEST(UpsampleOpTest, UpsampleOpNearestTest_int32) {
|
|||
7, 7, 7, 9, 9, 9};
|
||||
|
||||
test.AddOutput<int32_t>("Y", {N, C, (int64_t)(H * scales[2]), (int64_t)(W * scales[3])}, Y);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(UpsampleOpTest, UpsampleOpNearestTest_uint8) {
|
||||
|
|
@ -98,7 +100,7 @@ TEST(UpsampleOpTest, UpsampleOpNearestTest_uint8) {
|
|||
7, 7, 7, 9, 9, 9};
|
||||
|
||||
test.AddOutput<uint8_t>("Y", {N, C, (int64_t)(H * scales[2]), (int64_t)(W * scales[3])}, Y);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT: unsupported data type
|
||||
}
|
||||
|
||||
TEST(UpsampleOpTest, UpsampleOpNearest2XTest) {
|
||||
|
|
@ -171,7 +173,7 @@ TEST(UpsampleOpTest, UpsampleOpNearest222XTest) {
|
|||
};
|
||||
|
||||
test.AddOutput<float>("Y", {N*2, C, (int64_t)(H * scales[2]), (int64_t)(W * scales[3])}, Y);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT parser: Assertion failed: scales[0] == 1 && scales[1] == 1
|
||||
}
|
||||
|
||||
TEST(UpsampleOpTest, UpsampleOpNearest15XTest) {
|
||||
|
|
@ -233,7 +235,7 @@ TEST(UpsampleOpTest, UpsampleOpNearest2XTest_int32) {
|
|||
7, 7, 9, 9};
|
||||
|
||||
test.AddOutput<int32_t>("Y", {N, C, (int64_t)(H * scales[2]), (int64_t)(W * scales[3])}, Y);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(UpsampleOpTest, UpsampleOpBilinearTest) {
|
||||
|
|
@ -264,7 +266,7 @@ TEST(UpsampleOpTest, UpsampleOpBilinearTest) {
|
|||
7.0f, 7.5f, 8.0f, 8.5f, 9.0f, 9.0f, 9.0f, 9.0f};
|
||||
|
||||
test.AddOutput<float>("Y", {N, C, (int64_t)(H * scales[2]), (int64_t)(W * scales[3])}, Y);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT parser:Assertion failed: mode == "nearest"
|
||||
}
|
||||
|
||||
TEST(UpsampleOpTest, UpsampleOpBilinearTest2) {
|
||||
|
|
@ -295,7 +297,7 @@ TEST(UpsampleOpTest, UpsampleOpBilinearTest2) {
|
|||
7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 11.0f, 11.0f, 11.0f};
|
||||
|
||||
test.AddOutput<float>("Y", {N, C, (int64_t)(H * scales[2]), (int64_t)(W * scales[3])}, Y);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT parser:Assertion failed: mode == "nearest"
|
||||
}
|
||||
|
||||
TEST(UpsampleOpTest, UpsampleOpBilinearTest_int32) {
|
||||
|
|
@ -326,7 +328,7 @@ TEST(UpsampleOpTest, UpsampleOpBilinearTest_int32) {
|
|||
7, 7, 8, 8, 9, 9, 9, 9};
|
||||
|
||||
test.AddOutput<int32_t>("Y", {N, C, (int64_t)(H * scales[2]), (int64_t)(W * scales[3])}, Y);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT parser:Assertion failed: mode == "nearest"
|
||||
}
|
||||
|
||||
TEST(UpsampleOpTest, UpsampleOpNearestTest_1D) {
|
||||
|
|
@ -348,7 +350,7 @@ TEST(UpsampleOpTest, UpsampleOpNearestTest_1D) {
|
|||
5.0f, 5.0f};
|
||||
|
||||
test.AddOutput<float>("Y", {10}, Y);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT parser:Assertion failed: tensor.getDimensions().nbDims == 3
|
||||
}
|
||||
|
||||
TEST(UpsampleOpTest, UpsampleOpNearest2XTest_opset9) {
|
||||
|
|
@ -379,7 +381,7 @@ TEST(UpsampleOpTest, UpsampleOpNearest2XTest_opset9) {
|
|||
7, 7, 9, 9};
|
||||
|
||||
test.AddOutput<int32_t>("Y", {N, C, (int64_t)(H * scales[2]), (int64_t)(W * scales[3])}, Y);
|
||||
test.Run();
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});//TensorRT parser:Assertion failed: scales_input.is_weights()
|
||||
}
|
||||
} // namespace test
|
||||
} // namespace onnxruntime
|
||||
|
|
|
|||
|
|
@ -466,7 +466,9 @@ void OpTester::Run(ExpectResult expect_result,
|
|||
continue;
|
||||
|
||||
//if node is not registered for the provider, skip
|
||||
node.SetExecutionProviderType(provider_type);
|
||||
node.SetExecutionProviderType(provider_type);
|
||||
if (provider_type == onnxruntime::kTensorrtExecutionProvider)
|
||||
continue;
|
||||
auto reg = execution_provider->GetKernelRegistry();
|
||||
const KernelCreateInfo* kci = reg->TryFindKernel(node, execution_provider->Type());
|
||||
if (!kci) {
|
||||
|
|
|
|||
|
|
@ -482,6 +482,12 @@ def setup_tensorrt_vars(args):
|
|||
"tensorrt_home='{}' valid={}."
|
||||
.format(tensorrt_home, tensorrt_home_valid))
|
||||
|
||||
# Set maximum batch size for TensorRT. The number needs to be no less than maximum batch size in all unit tests
|
||||
os.environ["ORT_TENSORRT_MAX_BATCH_SIZE"] = "13"
|
||||
|
||||
# Set maximum workspace size in byte for TensorRT (1GB = 1073741824 bytes).
|
||||
os.environ["ORT_TENSORRT_MAX_WORKSPACE_SIZE"] = "1073741824"
|
||||
|
||||
return tensorrt_home
|
||||
|
||||
def run_onnxruntime_tests(args, source_dir, ctest_path, build_dir, configs, enable_python_tests, enable_tvm = False, enable_tensorrt = False):
|
||||
|
|
|
|||
Loading…
Reference in a new issue