Commit af1201fd authored by Jayaram Bobba's avatar Jayaram Bobba Committed by Robert Kimball

Remove validation checks from performance critical code paths and ski… (#1327)

* Remove validation checks from performance critical code paths and skip layout propagation to inputs

* Add templated call method to backend for cases where users need input validation

* Added missing return

* fix python api compile error due to ngraph api change.

* disable parameter validation in python api

* make validating call a separate call rather than templated
parent 61c606e7
...@@ -90,6 +90,18 @@ public: ...@@ -90,6 +90,18 @@ public:
const std::vector<std::shared_ptr<runtime::TensorView>>& outputs, const std::vector<std::shared_ptr<runtime::TensorView>>& outputs,
const std::vector<std::shared_ptr<runtime::TensorView>>& inputs) = 0; const std::vector<std::shared_ptr<runtime::TensorView>>& inputs) = 0;
/// @brief Executes a single iteration of a Function. If func is not compiled the call will
/// compile it. Optionally validates the inputs and outputs against the function graph.
/// @param func The function to execute
/// @returns true if iteration is successful, false otherwise
bool call_with_validate(std::shared_ptr<Function> func,
const std::vector<std::shared_ptr<runtime::TensorView>>& outputs,
const std::vector<std::shared_ptr<runtime::TensorView>>& inputs)
{
validate_call(func, outputs, inputs);
return call(func, outputs, inputs);
}
/// @brief Compiled functions may be cached. This function removes a compiled function /// @brief Compiled functions may be cached. This function removes a compiled function
/// from the cache. /// from the cache.
/// @param func The function to execute /// @param func The function to execute
......
...@@ -80,8 +80,6 @@ bool runtime::cpu::CPU_Backend::call(shared_ptr<Function> func, ...@@ -80,8 +80,6 @@ bool runtime::cpu::CPU_Backend::call(shared_ptr<Function> func,
{ {
bool rc = true; bool rc = true;
validate_call(func, outputs, inputs);
FunctionInstance& instance = m_function_map[func]; FunctionInstance& instance = m_function_map[func];
if (instance.m_external_function == nullptr) if (instance.m_external_function == nullptr)
{ {
......
...@@ -45,7 +45,6 @@ void runtime::cpu::CPU_CallFrame::call( ...@@ -45,7 +45,6 @@ void runtime::cpu::CPU_CallFrame::call(
vector<void*> inputs; vector<void*> inputs;
vector<void*> outputs; vector<void*> outputs;
propagate_layouts(input_tvs, m_external_function->get_parameter_layout_descriptors());
propagate_layouts(output_tvs, m_external_function->get_result_layout_descriptors()); propagate_layouts(output_tvs, m_external_function->get_result_layout_descriptors());
for (size_t i = 0; i < input_tvs.size(); i++) for (size_t i = 0; i < input_tvs.size(); i++)
......
...@@ -8363,7 +8363,7 @@ NGRAPH_TEST(${BACKEND_NAME}, validate_call_input_count) ...@@ -8363,7 +8363,7 @@ NGRAPH_TEST(${BACKEND_NAME}, validate_call_input_count)
auto b = backend->create_tensor(element::f32, shape); auto b = backend->create_tensor(element::f32, shape);
auto c = backend->create_tensor(element::f32, shape); auto c = backend->create_tensor(element::f32, shape);
EXPECT_ANY_THROW(backend->call(f, {c}, {a})); EXPECT_ANY_THROW(backend->call_with_validate(f, {c}, {a}));
} }
NGRAPH_TEST(${BACKEND_NAME}, validate_call_input_type) NGRAPH_TEST(${BACKEND_NAME}, validate_call_input_type)
...@@ -8380,7 +8380,7 @@ NGRAPH_TEST(${BACKEND_NAME}, validate_call_input_type) ...@@ -8380,7 +8380,7 @@ NGRAPH_TEST(${BACKEND_NAME}, validate_call_input_type)
auto b = backend->create_tensor(element::f32, shape); auto b = backend->create_tensor(element::f32, shape);
auto c = backend->create_tensor(element::f32, shape); auto c = backend->create_tensor(element::f32, shape);
EXPECT_ANY_THROW(backend->call(f, {c}, {a, b})); EXPECT_ANY_THROW(backend->call_with_validate(f, {c}, {a, b}));
} }
NGRAPH_TEST(${BACKEND_NAME}, validate_call_input_shape) NGRAPH_TEST(${BACKEND_NAME}, validate_call_input_shape)
...@@ -8397,7 +8397,7 @@ NGRAPH_TEST(${BACKEND_NAME}, validate_call_input_shape) ...@@ -8397,7 +8397,7 @@ NGRAPH_TEST(${BACKEND_NAME}, validate_call_input_shape)
auto b = backend->create_tensor(element::f32, shape); auto b = backend->create_tensor(element::f32, shape);
auto c = backend->create_tensor(element::f32, shape); auto c = backend->create_tensor(element::f32, shape);
EXPECT_ANY_THROW(backend->call(f, {c}, {a, b})); EXPECT_ANY_THROW(backend->call_with_validate(f, {c}, {a, b}));
} }
NGRAPH_TEST(${BACKEND_NAME}, validate_call_output_count) NGRAPH_TEST(${BACKEND_NAME}, validate_call_output_count)
...@@ -8415,7 +8415,7 @@ NGRAPH_TEST(${BACKEND_NAME}, validate_call_output_count) ...@@ -8415,7 +8415,7 @@ NGRAPH_TEST(${BACKEND_NAME}, validate_call_output_count)
auto c = backend->create_tensor(element::f32, shape); auto c = backend->create_tensor(element::f32, shape);
auto d = backend->create_tensor(element::f32, shape); auto d = backend->create_tensor(element::f32, shape);
EXPECT_ANY_THROW(backend->call(f, {c, d}, {a, b})); EXPECT_ANY_THROW(backend->call_with_validate(f, {c, d}, {a, b}));
} }
NGRAPH_TEST(${BACKEND_NAME}, validate_call_output_type) NGRAPH_TEST(${BACKEND_NAME}, validate_call_output_type)
...@@ -8432,7 +8432,7 @@ NGRAPH_TEST(${BACKEND_NAME}, validate_call_output_type) ...@@ -8432,7 +8432,7 @@ NGRAPH_TEST(${BACKEND_NAME}, validate_call_output_type)
auto b = backend->create_tensor(element::f32, shape); auto b = backend->create_tensor(element::f32, shape);
auto c = backend->create_tensor(element::f32, shape); auto c = backend->create_tensor(element::f32, shape);
EXPECT_ANY_THROW(backend->call(f, {a}, {b, c})); EXPECT_ANY_THROW(backend->call_with_validate(f, {a}, {b, c}));
} }
NGRAPH_TEST(${BACKEND_NAME}, validate_call_output_shape) NGRAPH_TEST(${BACKEND_NAME}, validate_call_output_shape)
...@@ -8449,7 +8449,7 @@ NGRAPH_TEST(${BACKEND_NAME}, validate_call_output_shape) ...@@ -8449,7 +8449,7 @@ NGRAPH_TEST(${BACKEND_NAME}, validate_call_output_shape)
auto b = backend->create_tensor(element::f32, shape); auto b = backend->create_tensor(element::f32, shape);
auto c = backend->create_tensor(element::f32, shape); auto c = backend->create_tensor(element::f32, shape);
EXPECT_ANY_THROW(backend->call(f, {a}, {c, b})); EXPECT_ANY_THROW(backend->call_with_validate(f, {a}, {c, b}));
} }
NGRAPH_TEST(${BACKEND_NAME}, logical_and) NGRAPH_TEST(${BACKEND_NAME}, logical_and)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment