Unverified Commit 3932d53e authored by Adam Procter's avatar Adam Procter Committed by GitHub

Merge branch 'master' into krovatkin/memory_bug_fix1

parents d33da489 d380f40e
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
/cmake/ @rkimballn1 @silee2 /cmake/ @rkimballn1 @silee2
/.ci/ @aslepko @crlishka /.ci/ @aslepko
/.ci/travis/ @postrational /.ci/travis/ @aslepko @postrational
/.ci/onnx/ @postrational /.ci/onnx/ @aslepko @postrational
/contrib/docker/ @aslepko @crlishka /contrib/docker/ @aslepko
/.travis.yml @postrational /.travis.yml @aslepko @postrational
/.clang-format @rkimballn1 /.clang-format @rkimballn1
/.gitattributes @rkimballn1 /.gitattributes @rkimballn1
......
...@@ -42,3 +42,7 @@ add_custom_command( ...@@ -42,3 +42,7 @@ add_custom_command(
) )
add_custom_target(python_wheel DEPENDS ngraph ${CMAKE_BINARY_DIR}/python/dist/) add_custom_target(python_wheel DEPENDS ngraph ${CMAKE_BINARY_DIR}/python/dist/)
if (NGRAPH_CPU_ENABLE)
add_dependencies(python_wheel ext_mkldnn)
endif()
...@@ -15,8 +15,12 @@ ...@@ -15,8 +15,12 @@
# ****************************************************************************** # ******************************************************************************
"""ngraph module namespace, exposing factory functions for all ops and other classes.""" """ngraph module namespace, exposing factory functions for all ops and other classes."""
from pkg_resources import get_distribution from pkg_resources import get_distribution, DistributionNotFound
__version__ = get_distribution('ngraph-core').version
try:
__version__ = get_distribution('ngraph-core').version
except DistributionNotFound:
__version__ = '0.0.0-dev'
from ngraph.ops import absolute from ngraph.ops import absolute
from ngraph.ops import absolute as abs from ngraph.ops import absolute as abs
......
...@@ -374,6 +374,10 @@ class BuildExt(build_ext): ...@@ -374,6 +374,10 @@ class BuildExt(build_ext):
build_ext.build_extensions(self) build_ext.build_extensions(self)
if sys.platform == 'darwin':
# This turns out to be needed when building using Anaconda python on macOS.
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'
with open(os.path.join(PYNGRAPH_ROOT_DIR, 'requirements.txt')) as req: with open(os.path.join(PYNGRAPH_ROOT_DIR, 'requirements.txt')) as req:
requirements = req.read().splitlines() requirements = req.read().splitlines()
......
...@@ -99,6 +99,14 @@ namespace ngraph ...@@ -99,6 +99,14 @@ namespace ngraph
return op_list; return op_list;
} }
bool is_operator_supported(const std::string& op_name,
std::int64_t version,
const std::string& domain)
{
return OperatorsBridge::is_operator_registered(
op_name, version, domain == "ai.onnx" ? "" : domain);
}
} // namespace onnx_import } // namespace onnx_import
} // namespace ngraph } // namespace ngraph
...@@ -52,6 +52,18 @@ namespace ngraph ...@@ -52,6 +52,18 @@ namespace ngraph
std::set<std::string> get_supported_operators(std::int64_t version, std::set<std::string> get_supported_operators(std::int64_t version,
const std::string& domain); const std::string& domain);
/// \brief Determines whether ONNX operator is supported.
///
/// \param[in] op_name The ONNX operator name.
/// \param[in] version The ONNX operator set version.
/// \param[in] domain The domain the ONNX operator is registered to.
///
/// \return True if operator is supported, False otherwise.
///
bool is_operator_supported(const std::string& op_name,
std::int64_t version,
const std::string& domain = "ai.onnx");
/// \brief Convert an ONNX model to nGraph function /// \brief Convert an ONNX model to nGraph function
/// The function translated serialized ONNX model to nGraph function. The serialized /// The function translated serialized ONNX model to nGraph function. The serialized
/// ONNX model is read from input stream. /// ONNX model is read from input stream.
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <unordered_map> #include <unordered_map>
#include "core/attribute.hpp" #include "core/attribute.hpp"
#include "ngraph/log.hpp"
#include "op/abs.hpp" #include "op/abs.hpp"
#include "op/acos.hpp" #include "op/acos.hpp"
#include "op/add.hpp" #include "op/add.hpp"
...@@ -102,20 +103,19 @@ namespace ngraph ...@@ -102,20 +103,19 @@ namespace ngraph
{ {
namespace detail namespace detail
{ {
const Operator& find(const std::string& name, const std::map<std::int64_t, Operator>::const_iterator
std::int64_t version, find(std::int64_t version, const std::map<std::int64_t, Operator>& map)
const std::string& domain,
const std::map<std::int64_t, Operator>& map)
{ {
std::map<std::int64_t, Operator>::const_iterator it{};
while (version > 0) while (version > 0)
{ {
const auto it = map.find(version--); it = map.find(version--);
if (it != std::end(map)) if (it != std::end(map))
{ {
return it->second; return it;
} }
} }
throw error::UnsupportedVersion{name, version, domain}; return it;
} }
} }
...@@ -136,13 +136,51 @@ namespace ngraph ...@@ -136,13 +136,51 @@ namespace ngraph
{ {
throw error::UnknownDomain{domain}; throw error::UnknownDomain{domain};
} }
if (version > OperatorsBridge::LATEST_SUPPORTED_OPSET_VERSION)
{
NGRAPH_WARN << "Currently operator set version: " << version << " is unsupported."
<< " Falling back to: "
<< OperatorsBridge::LATEST_SUPPORTED_OPSET_VERSION;
}
for (const auto& op : dm->second) for (const auto& op : dm->second)
{ {
result.emplace(op.first, detail::find(op.first, version, domain, op.second)); const auto& it = detail::find(version, op.second);
if (it == std::end(op.second))
{
throw error::UnsupportedVersion{op.first, version, domain};
}
result.emplace(op.first, it->second);
} }
return result; return result;
} }
bool OperatorsBridge::_is_operator_registered(const std::string& name,
std::int64_t version,
const std::string& domain)
{
// search for domain
auto dm_map = m_map.find(domain);
if (dm_map == std::end(m_map))
{
return false;
}
// search for name
auto op_map = dm_map->second.find(name);
if (op_map == std::end(dm_map->second))
{
return false;
}
if (detail::find(version, op_map->second) != std::end(op_map->second))
{
return true;
}
else
{
return false;
}
}
#define REGISTER_OPERATOR(name_, ver_, fn_) \ #define REGISTER_OPERATOR(name_, ver_, fn_) \
m_map[""][name_].emplace(ver_, std::bind(op::set_##ver_::fn_, std::placeholders::_1)) m_map[""][name_].emplace(ver_, std::bind(op::set_##ver_::fn_, std::placeholders::_1))
......
...@@ -62,6 +62,8 @@ namespace ngraph ...@@ -62,6 +62,8 @@ namespace ngraph
class OperatorsBridge class OperatorsBridge
{ {
public: public:
static constexpr const int LATEST_SUPPORTED_OPSET_VERSION = ONNX_OPSET_VERSION;
OperatorsBridge(const OperatorsBridge&) = delete; OperatorsBridge(const OperatorsBridge&) = delete;
OperatorsBridge& operator=(const OperatorsBridge&) = delete; OperatorsBridge& operator=(const OperatorsBridge&) = delete;
OperatorsBridge(OperatorsBridge&&) = delete; OperatorsBridge(OperatorsBridge&&) = delete;
...@@ -80,6 +82,13 @@ namespace ngraph ...@@ -80,6 +82,13 @@ namespace ngraph
instance()._register_operator(name, version, domain, std::move(fn)); instance()._register_operator(name, version, domain, std::move(fn));
} }
static bool is_operator_registered(const std::string& name,
std::int64_t version,
const std::string& domain)
{
return instance()._is_operator_registered(name, version, domain);
}
private: private:
std::unordered_map<std::string, std::unordered_map<std::string,
std::unordered_map<std::string, std::map<std::int64_t, Operator>>> std::unordered_map<std::string, std::map<std::int64_t, Operator>>>
...@@ -98,6 +107,9 @@ namespace ngraph ...@@ -98,6 +107,9 @@ namespace ngraph
const std::string& domain, const std::string& domain,
Operator fn); Operator fn);
OperatorSet _get_operator_set(std::int64_t version, const std::string& domain); OperatorSet _get_operator_set(std::int64_t version, const std::string& domain);
bool _is_operator_registered(const std::string& name,
std::int64_t version,
const std::string& domain);
}; };
} // namespace onnx_import } // namespace onnx_import
......
...@@ -73,6 +73,8 @@ bool pass::MemoryLayout::run_on_function(shared_ptr<ngraph::Function> function) ...@@ -73,6 +73,8 @@ bool pass::MemoryLayout::run_on_function(shared_ptr<ngraph::Function> function)
node->liveness_new_list.count(output) != 0) node->liveness_new_list.count(output) != 0)
{ {
NGRAPH_DEBUG << "Reusing " << input->get_name() << " for "
<< output->get_name();
in_place_outputs.insert({output, input}); in_place_outputs.insert({output, input});
reused_inputs.insert(input); reused_inputs.insert(input);
} }
......
...@@ -29,22 +29,30 @@ ...@@ -29,22 +29,30 @@
#include "ngraph/op/convolution.hpp" #include "ngraph/op/convolution.hpp"
#include "ngraph/op/dequantize.hpp" #include "ngraph/op/dequantize.hpp"
#include "ngraph/op/get_output_element.hpp" #include "ngraph/op/get_output_element.hpp"
#include "ngraph/op/pad.hpp"
#include "ngraph/op/quantize.hpp" #include "ngraph/op/quantize.hpp"
#include "ngraph/op/reshape.hpp" #include "ngraph/op/reshape.hpp"
#include "ngraph/op/slice.hpp"
#include "ngraph/op/util/binary_elementwise_arithmetic.hpp" #include "ngraph/op/util/binary_elementwise_arithmetic.hpp"
#include "ngraph/op/util/unary_elementwise_arithmetic.hpp" #include "ngraph/op/util/unary_elementwise_arithmetic.hpp"
#include "ngraph/pattern/op/label.hpp"
#include "ngraph/util.hpp" #include "ngraph/util.hpp"
using namespace ngraph; using namespace ngraph;
extern template ngraph::AxisVector using ReshapeMap = std::unordered_map<std::shared_ptr<Node>, std::shared_ptr<op::Reshape>>;
ngraph::apply_permutation<ngraph::AxisVector>(ngraph::AxisVector input,
ngraph::AxisVector order);
extern template ngraph::Shape ngraph::apply_permutation<ngraph::Shape>(ngraph::Shape input, static std::string describe_reshape(std::shared_ptr<Node> node)
ngraph::AxisVector order); {
std::stringstream ss;
auto reshape = std::dynamic_pointer_cast<op::Reshape>(node);
ss << reshape->get_name()
<< " ( axis order = " << ngraph::vector_to_string(reshape->get_input_order())
<< " , shape = " << vector_to_string(reshape->get_shape()) << " ) "
<< " , child = " << reshape->get_argument(0)->get_name();
using ReshapeMap = std::unordered_map<std::shared_ptr<Node>, std::shared_ptr<op::Reshape>>; return ss.str();
}
static std::shared_ptr<op::Reshape> combine_reshapes(std::shared_ptr<op::Reshape> r1, static std::shared_ptr<op::Reshape> combine_reshapes(std::shared_ptr<op::Reshape> r1,
std::shared_ptr<op::Reshape> r2) std::shared_ptr<op::Reshape> r2)
...@@ -64,18 +72,6 @@ static void ...@@ -64,18 +72,6 @@ static void
target->get_inputs().at(input_index).replace_output(new_reshape->get_outputs().at(0)); target->get_inputs().at(input_index).replace_output(new_reshape->get_outputs().at(0));
} }
std::string describe_reshape(std::shared_ptr<Node> node)
{
std::stringstream ss;
auto reshape = std::dynamic_pointer_cast<op::Reshape>(node);
ss << reshape->get_name()
<< " ( axis order = " << ngraph::vector_to_string(reshape->get_input_order())
<< " , shape = " << vector_to_string(reshape->get_shape()) << " ) "
<< " , child = " << reshape->get_argument(0)->get_name();
return ss.str();
}
static void delete_reshape(std::shared_ptr<Node> reshape) static void delete_reshape(std::shared_ptr<Node> reshape)
{ {
NGRAPH_DEBUG << "Removing reshape " << reshape->get_name(); NGRAPH_DEBUG << "Removing reshape " << reshape->get_name();
...@@ -256,6 +252,7 @@ static void sink_reshape(std::shared_ptr<op::Reshape> reshape, ...@@ -256,6 +252,7 @@ static void sink_reshape(std::shared_ptr<op::Reshape> reshape,
mark_reshape_for_deletion(orig_reshape, reshapes_to_delete); mark_reshape_for_deletion(orig_reshape, reshapes_to_delete);
//replace reshape with combined one //replace reshape with combined one
ngraph::replace_node(reshape, new_reshape); ngraph::replace_node(reshape, new_reshape);
mark_reshape_for_deletion(new_reshape, reshapes_to_delete);
reorders[new_reshape] = new_reshape; reorders[new_reshape] = new_reshape;
NGRAPH_DEBUG << "Combining " << describe_reshape(orig_reshape) << " and" NGRAPH_DEBUG << "Combining " << describe_reshape(orig_reshape) << " and"
<< describe_reshape(reshape) << " into " << describe_reshape(new_reshape); << describe_reshape(reshape) << " into " << describe_reshape(new_reshape);
...@@ -309,6 +306,61 @@ static void sink_binary(std::shared_ptr<op::util::BinaryElementwiseArithmetic> b ...@@ -309,6 +306,61 @@ static void sink_binary(std::shared_ptr<op::util::BinaryElementwiseArithmetic> b
} }
} }
static void sink_slice(std::shared_ptr<op::Slice> n,
ReshapeMap& reorders,
std::set<std::shared_ptr<Node>>& reshapes_to_delete)
{
auto arg_reshape = reorders.at(n->get_argument(0));
auto order = arg_reshape->get_input_order();
// we need the correct input shape to produce the right output shape
// we are going to create a label of the right input shape,
// so a new slice will have the right shape
auto def_order = ngraph::get_permutation_to_default_order(order);
auto input_shape = ngraph::apply_permutation(arg_reshape->get_shape(), def_order);
auto dummy_correct_shape =
std::make_shared<pattern::op::Label>(arg_reshape->get_element_type(), input_shape);
auto new_lower = ngraph::apply_permutation(n->get_lower_bounds(), def_order);
auto new_upper = ngraph::apply_permutation(n->get_upper_bounds(), def_order);
auto new_strides = ngraph::apply_permutation(n->get_strides(), def_order);
auto new_slice =
std::make_shared<op::Slice>(dummy_correct_shape, new_lower, new_upper, new_strides);
ngraph::replace_node(dummy_correct_shape, n->get_argument(0));
NGRAPH_DEBUG << "Replacing " << n->get_name() << " with " << new_slice->get_name();
ngraph::replace_node(n, new_slice);
auto new_reshape = std::make_shared<op::Reshape>(new_slice, order, n->get_shape());
NGRAPH_DEBUG << "Propagating " << describe_reshape(new_reshape) << " for " << n->get_name();
reorders[new_slice] = new_reshape;
}
static void sink_pad(std::shared_ptr<op::Pad> n,
ReshapeMap& reorders,
std::set<std::shared_ptr<Node>>& reshapes_to_delete)
{
auto arg_reshape = reorders.at(n->get_argument(0));
auto order = arg_reshape->get_input_order();
// we need the correct input shape to produce the right output shape
// we are going to create a label of the right input shape,
// so a new pad will have the right shape
auto def_order = ngraph::get_permutation_to_default_order(order);
auto input_shape = ngraph::apply_permutation(arg_reshape->get_shape(), def_order);
auto dummy_correct_shape =
std::make_shared<pattern::op::Label>(arg_reshape->get_element_type(), input_shape);
auto new_lower = ngraph::apply_permutation(n->get_padding_below(), def_order);
auto new_upper = ngraph::apply_permutation(n->get_padding_above(), def_order);
auto new_interior = ngraph::apply_permutation(n->get_padding_interior(), def_order);
auto new_pad = std::make_shared<op::Pad>(
dummy_correct_shape, n->get_argument(1), new_lower, new_upper, new_interior);
ngraph::replace_node(dummy_correct_shape, n->get_argument(0));
NGRAPH_DEBUG << "Replacing " << n->get_name() << " with " << new_pad->get_name();
ngraph::replace_node(n, new_pad);
auto new_reshape = std::make_shared<op::Reshape>(new_pad, order, n->get_shape());
NGRAPH_DEBUG << "Propagating " << describe_reshape(new_reshape) << " for " << n->get_name();
reorders[new_pad] = new_reshape;
}
static void sink_quantize(std::shared_ptr<op::Quantize> quantize, static void sink_quantize(std::shared_ptr<op::Quantize> quantize,
ReshapeMap& reorders, ReshapeMap& reorders,
std::set<std::shared_ptr<Node>>& reshapes_to_delete) std::set<std::shared_ptr<Node>>& reshapes_to_delete)
...@@ -419,6 +471,14 @@ bool ngraph::pass::ReshapeSinking::run_on_function(std::shared_ptr<ngraph::Funct ...@@ -419,6 +471,14 @@ bool ngraph::pass::ReshapeSinking::run_on_function(std::shared_ptr<ngraph::Funct
{ {
sink_dequantize(dequantize, reorders, reshapes_to_delete); sink_dequantize(dequantize, reorders, reshapes_to_delete);
} }
else if (auto slice = std::dynamic_pointer_cast<op::Slice>(n))
{
sink_slice(slice, reorders, reshapes_to_delete);
}
else if (auto pad = std::dynamic_pointer_cast<op::Pad>(n))
{
sink_pad(pad, reorders, reshapes_to_delete);
}
else else
{ {
materialize_shapes(n, reorders, reshapes_to_delete); materialize_shapes(n, reorders, reshapes_to_delete);
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#pragma once #pragma once
#include "ngraph/pass/pass.hpp" #include "ngraph/pass/pass.hpp"
#include "ngraph/util.hpp"
namespace ngraph namespace ngraph
{ {
...@@ -29,3 +30,17 @@ namespace ngraph ...@@ -29,3 +30,17 @@ namespace ngraph
}; };
} }
} }
extern template ngraph::AxisVector
ngraph::apply_permutation<ngraph::AxisVector>(ngraph::AxisVector input,
ngraph::AxisVector order);
extern template ngraph::Coordinate
ngraph::apply_permutation<ngraph::Coordinate>(ngraph::Coordinate input,
ngraph::AxisVector order);
extern template ngraph::Strides
ngraph::apply_permutation<ngraph::Strides>(ngraph::Strides input, ngraph::AxisVector order);
extern template ngraph::Shape ngraph::apply_permutation<ngraph::Shape>(ngraph::Shape input,
ngraph::AxisVector order);
...@@ -145,3 +145,8 @@ vector<runtime::PerformanceCounter> ...@@ -145,3 +145,8 @@ vector<runtime::PerformanceCounter>
} }
return rc; return rc;
} }
bool runtime::cpu::CPU_Backend::is_supported(const Node& op) const
{
return true;
}
...@@ -58,6 +58,8 @@ namespace ngraph ...@@ -58,6 +58,8 @@ namespace ngraph
std::vector<PerformanceCounter> std::vector<PerformanceCounter>
get_performance_data(std::shared_ptr<Function> func) const override; get_performance_data(std::shared_ptr<Function> func) const override;
bool is_supported(const Node& node) const override;
private: private:
class FunctionInstance class FunctionInstance
{ {
......
...@@ -1982,10 +1982,10 @@ void runtime::cpu::CPU_ExternalFunction::build() ...@@ -1982,10 +1982,10 @@ void runtime::cpu::CPU_ExternalFunction::build()
file_util::path_join(s_debug_dir, m_function_name + "_debug.txt"); file_util::path_join(s_debug_dir, m_function_name + "_debug.txt");
std::stringstream ss; std::stringstream ss;
ss << "EXECUTION PLAN:\n"; ss << "\nEXECUTION PLAN:\n";
for (size_t i = 0; i < functors.size(); i++) for (size_t i = 0; i < functors.size(); i++)
{ {
ss << op_names.at(i) << "will be executed with the following inputs:\n"; ss << op_names.at(i) << " will be executed with the following inputs:\n";
for (auto is : this->m_op_attrs.at(i).Inputs) for (auto is : this->m_op_attrs.at(i).Inputs)
{ {
ss << "\t" << is << " = " << this->get_tensor_data(is) << std::endl; ss << "\t" << is << " = " << this->get_tensor_data(is) << std::endl;
......
...@@ -18,13 +18,10 @@ ...@@ -18,13 +18,10 @@
#include "ngraph/graph_util.hpp" #include "ngraph/graph_util.hpp"
#include "ngraph/pass/manager.hpp" #include "ngraph/pass/manager.hpp"
#include "ngraph/pass/visualize_tree.hpp" #include "ngraph/pass/visualize_tree.hpp"
#include "ngraph/runtime/gpu/gpu_backend.hpp"
#include "ngraph/runtime/gpu/gpu_tensor.hpp"
#include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/host_tensor.hpp"
#include "ngraph/runtime/hybrid/hybrid_util.hpp" #include "ngraph/runtime/hybrid/hybrid_util.hpp"
#include "ngraph/runtime/hybrid/pass/assign_placement.hpp" #include "ngraph/runtime/hybrid/pass/assign_placement.hpp"
#include "ngraph/runtime/hybrid/pass/fix_get_output_element.hpp" #include "ngraph/runtime/hybrid/pass/fix_get_output_element.hpp"
#include "ngraph/runtime/interpreter/int_backend.hpp"
#include "ngraph/runtime/tensor.hpp" #include "ngraph/runtime/tensor.hpp"
using namespace ngraph; using namespace ngraph;
...@@ -205,32 +202,6 @@ bool runtime::hybrid::HybridBackend::is_supported(const Node& node) const ...@@ -205,32 +202,6 @@ bool runtime::hybrid::HybridBackend::is_supported(const Node& node) const
return true; return true;
} }
string runtime::hybrid::HybridBackend::get_placement_name(const runtime::Tensor* t)
{
string rc;
if (dynamic_cast<const runtime::HostTensor*>(t) != nullptr)
{
rc = "HostTensor";
}
else if (dynamic_cast<const runtime::gpu::GPUTensor*>(t) != nullptr)
{
rc = "GPUTensor";
}
return rc;
}
string runtime::hybrid::HybridBackend::get_placement_name(const runtime::Backend* t)
{
string rc;
if (dynamic_cast<const runtime::interpreter::INTBackend*>(t) != nullptr)
{
rc = "INTBackend";
}
else if (dynamic_cast<const runtime::gpu::GPU_Backend*>(t) != nullptr)
{
rc = "GPU_Backend";
}
return rc;
}
size_t runtime::hybrid::HybridBackend::get_placement(const runtime::Tensor* t) size_t runtime::hybrid::HybridBackend::get_placement(const runtime::Tensor* t)
{ {
size_t index = 0; size_t index = 0;
......
...@@ -70,7 +70,5 @@ private: ...@@ -70,7 +70,5 @@ private:
std::map<std::shared_ptr<ngraph::Function>, FunctionInstance> m_function_map; std::map<std::shared_ptr<ngraph::Function>, FunctionInstance> m_function_map;
std::vector<std::shared_ptr<runtime::Backend>> m_backend_list; std::vector<std::shared_ptr<runtime::Backend>> m_backend_list;
std::string get_placement_name(const runtime::Tensor* t);
std::string get_placement_name(const runtime::Backend* t);
size_t get_placement(const runtime::Tensor* t); size_t get_placement(const runtime::Tensor* t);
}; };
...@@ -478,6 +478,10 @@ T ngraph::apply_permutation(T input, AxisVector order) ...@@ -478,6 +478,10 @@ T ngraph::apply_permutation(T input, AxisVector order)
template AxisVector ngraph::apply_permutation<AxisVector>(AxisVector input, AxisVector order); template AxisVector ngraph::apply_permutation<AxisVector>(AxisVector input, AxisVector order);
template Shape ngraph::apply_permutation<Shape>(Shape input, AxisVector order); template Shape ngraph::apply_permutation<Shape>(Shape input, AxisVector order);
template ngraph::Coordinate ngraph::apply_permutation<ngraph::Coordinate>(ngraph::Coordinate input,
ngraph::AxisVector order);
template ngraph::Strides ngraph::apply_permutation<ngraph::Strides>(ngraph::Strides input,
ngraph::AxisVector order);
AxisVector ngraph::get_default_order(const Shape& shape) AxisVector ngraph::get_default_order(const Shape& shape)
{ {
......
...@@ -65,13 +65,6 @@ set(SRC ...@@ -65,13 +65,6 @@ set(SRC
set_source_files_properties(includes.cpp PROPERTIES COMPILE_DEFINITIONS set_source_files_properties(includes.cpp PROPERTIES COMPILE_DEFINITIONS
NGRAPH_INCLUDES="${PROJECT_SOURCE_DIR}/src/ngraph") NGRAPH_INCLUDES="${PROJECT_SOURCE_DIR}/src/ngraph")
if (NGRAPH_ONNX_IMPORT_ENABLE)
list(APPEND SRC onnx_import.cpp)
if (NGRAPH_ONNXIFI_ENABLE)
list(APPEND SRC onnxifi.cpp onnxifi_span.cpp)
endif()
endif()
if (NGRAPH_INTERPRETER_ENABLE) if (NGRAPH_INTERPRETER_ENABLE)
list(APPEND SRC list(APPEND SRC
backend_debug_api.cpp backend_debug_api.cpp
...@@ -140,13 +133,22 @@ set(MULTI_TEST_SRC ...@@ -140,13 +133,22 @@ set(MULTI_TEST_SRC
backend_unary_elementwise.in.cpp backend_unary_elementwise.in.cpp
convolution_test.in.cpp convolution_test.in.cpp
) )
if(NGRAPH_DISTRIBUTED_ENABLE) if(NGRAPH_DISTRIBUTED_ENABLE)
list(APPEND MULTI_TEST_SRC distributed.in.cpp) list(APPEND MULTI_TEST_SRC distributed.in.cpp)
endif() endif()
if (NGRAPH_CPU_ENABLE) if (NGRAPH_CPU_ENABLE)
list(APPEND MULTI_TEST_SRC backend_graph_comparison.in.cpp) list(APPEND MULTI_TEST_SRC backend_graph_comparison.in.cpp)
endif() endif()
if (NGRAPH_ONNX_IMPORT_ENABLE)
list(APPEND MULTI_TEST_SRC onnx_import.in.cpp)
if (NGRAPH_ONNXIFI_ENABLE)
list(APPEND SRC onnxifi.cpp onnxifi_span.cpp)
endif()
endif()
foreach(BACKEND_NAME ${ACTIVE_BACKEND_LIST}) foreach(BACKEND_NAME ${ACTIVE_BACKEND_LIST})
# Some---but not all---autodiff tests go through multiple iterations with # Some---but not all---autodiff tests go through multiple iterations with
# different random seeds. On the CPU backend this is currently very slow # different random seeds. On the CPU backend this is currently very slow
......
...@@ -32,10 +32,12 @@ ...@@ -32,10 +32,12 @@
using namespace ngraph; using namespace ngraph;
static std::string s_manifest = "${MANIFEST}";
using Inputs = std::vector<std::vector<float>>; using Inputs = std::vector<std::vector<float>>;
using Outputs = std::vector<std::vector<float>>; using Outputs = std::vector<std::vector<float>>;
TEST(onnx, model_output_names_check) TEST(onnx_${BACKEND_NAME}, model_output_names_check)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/split_equal_parts_default.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/split_equal_parts_default.onnx"));
...@@ -48,7 +50,7 @@ TEST(onnx, model_output_names_check) ...@@ -48,7 +50,7 @@ TEST(onnx, model_output_names_check)
} }
} }
TEST(onnx, model_add_abc) TEST(onnx_${BACKEND_NAME}, model_add_abc)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc.onnx"));
...@@ -56,11 +58,11 @@ TEST(onnx, model_add_abc) ...@@ -56,11 +58,11 @@ TEST(onnx, model_add_abc)
Inputs inputs{{1}, {2}, {3}}; Inputs inputs{{1}, {2}, {3}};
Outputs expected_outputs{{6}}; Outputs expected_outputs{{6}};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_add_abc_initializers) TEST(onnx_${BACKEND_NAME}, model_add_abc_initializers)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc_initializers.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc_initializers.onnx"));
...@@ -68,11 +70,11 @@ TEST(onnx, model_add_abc_initializers) ...@@ -68,11 +70,11 @@ TEST(onnx, model_add_abc_initializers)
Inputs inputs{{1, 2, 3, 4}}; Inputs inputs{{1, 2, 3, 4}};
Outputs expected_outputs{{3, 6, 9, 12}}; Outputs expected_outputs{{3, 6, 9, 12}};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_addmul_abc) TEST(onnx_${BACKEND_NAME}, model_addmul_abc)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/addmul_abc.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/addmul_abc.onnx"));
...@@ -86,11 +88,11 @@ TEST(onnx, model_addmul_abc) ...@@ -86,11 +88,11 @@ TEST(onnx, model_addmul_abc)
auto expected_output = test::NDArray<float, 3>({{{46, 62}}, {{80, 100}}}).get_vector(); auto expected_output = test::NDArray<float, 3>({{{46, 62}}, {{80, 100}}}).get_vector();
auto result_vectors = execute(function, inputs, "INTERPRETER"); auto result_vectors = execute(function, inputs, "${BACKEND_NAME}");
EXPECT_TRUE(test::all_close_f(expected_output, result_vectors.front())); EXPECT_TRUE(test::all_close_f(expected_output, result_vectors.front()));
} }
TEST(onnx, model_argmin_no_keepdims) TEST(onnx_${BACKEND_NAME}, model_argmin_no_keepdims)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/argmin_no_keepdims.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/argmin_no_keepdims.onnx"));
...@@ -98,11 +100,11 @@ TEST(onnx, model_argmin_no_keepdims) ...@@ -98,11 +100,11 @@ TEST(onnx, model_argmin_no_keepdims)
Inputs inputs{test::NDArray<float, 2>{{2, 1}, {3, 10}}.get_vector()}; Inputs inputs{test::NDArray<float, 2>{{2, 1}, {3, 10}}.get_vector()};
std::vector<std::vector<int64_t>> expected_output{{1, 0}}; std::vector<std::vector<int64_t>> expected_output{{1, 0}};
std::vector<std::vector<int64_t>> result{ std::vector<std::vector<int64_t>> result{
execute<float, int64_t>(function, inputs, "INTERPRETER")}; execute<float, int64_t>(function, inputs, "${BACKEND_NAME}")};
EXPECT_EQ(expected_output, result); EXPECT_EQ(expected_output, result);
} }
TEST(onnx, model_split_equal_parts_default) TEST(onnx_${BACKEND_NAME}, model_split_equal_parts_default)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/split_equal_parts_default.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/split_equal_parts_default.onnx"));
...@@ -110,7 +112,7 @@ TEST(onnx, model_split_equal_parts_default) ...@@ -110,7 +112,7 @@ TEST(onnx, model_split_equal_parts_default)
Inputs inputs{{1, 2, 3, 4, 5, 6}}; Inputs inputs{{1, 2, 3, 4, 5, 6}};
Outputs expected_outputs{{1, 2}, {3, 4}, {5, 6}}; Outputs expected_outputs{{1, 2}, {3, 4}, {5, 6}};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_EQ(outputs.size(), expected_outputs.size()); EXPECT_EQ(outputs.size(), expected_outputs.size());
for (std::size_t i = 0; i < expected_outputs.size(); ++i) for (std::size_t i = 0; i < expected_outputs.size(); ++i)
...@@ -120,7 +122,7 @@ TEST(onnx, model_split_equal_parts_default) ...@@ -120,7 +122,7 @@ TEST(onnx, model_split_equal_parts_default)
} }
} }
TEST(onnx, model_split_equal_parts_2d) TEST(onnx_${BACKEND_NAME}, model_split_equal_parts_2d)
{ {
// Split into 2 equal parts along axis=1 // Split into 2 equal parts along axis=1
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
...@@ -129,7 +131,7 @@ TEST(onnx, model_split_equal_parts_2d) ...@@ -129,7 +131,7 @@ TEST(onnx, model_split_equal_parts_2d)
Inputs inputs{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; Inputs inputs{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}};
Outputs expected_outputs{{0, 1, 2, 6, 7, 8}, {3, 4, 5, 9, 10, 11}}; Outputs expected_outputs{{0, 1, 2, 6, 7, 8}, {3, 4, 5, 9, 10, 11}};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_EQ(outputs.size(), expected_outputs.size()); EXPECT_EQ(outputs.size(), expected_outputs.size());
for (std::size_t i = 0; i < expected_outputs.size(); ++i) for (std::size_t i = 0; i < expected_outputs.size(); ++i)
...@@ -139,7 +141,7 @@ TEST(onnx, model_split_equal_parts_2d) ...@@ -139,7 +141,7 @@ TEST(onnx, model_split_equal_parts_2d)
} }
} }
TEST(onnx, model_split_variable_parts_2d) TEST(onnx_${BACKEND_NAME}, model_split_variable_parts_2d)
{ {
// Split into variable parts {2, 4} along axis=1 // Split into variable parts {2, 4} along axis=1
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
...@@ -148,7 +150,7 @@ TEST(onnx, model_split_variable_parts_2d) ...@@ -148,7 +150,7 @@ TEST(onnx, model_split_variable_parts_2d)
Inputs inputs{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; Inputs inputs{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}};
Outputs expected_outputs{{0, 1, 6, 7}, {2, 3, 4, 5, 8, 9, 10, 11}}; Outputs expected_outputs{{0, 1, 6, 7}, {2, 3, 4, 5, 8, 9, 10, 11}};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_EQ(outputs.size(), expected_outputs.size()); EXPECT_EQ(outputs.size(), expected_outputs.size());
for (std::size_t i = 0; i < expected_outputs.size(); ++i) for (std::size_t i = 0; i < expected_outputs.size(); ++i)
...@@ -179,12 +181,12 @@ namespace ...@@ -179,12 +181,12 @@ namespace
test::NDArray<float, 4>{{{{{1.f, 1.f, 1.f}, {1.f, 1.f, 1.f}, {1.f, 1.f, 1.f}}}}} test::NDArray<float, 4>{{{{{1.f, 1.f, 1.f}, {1.f, 1.f, 1.f}, {1.f, 1.f, 1.f}}}}}
.get_vector()); .get_vector());
return execute(function, args, "INTERPRETER"); return execute(function, args, "${BACKEND_NAME}");
} }
} // namespace } // namespace
TEST(onnx, model_conv2d_strides_padding) TEST(onnx_${BACKEND_NAME}, model_conv2d_strides_padding)
{ {
// Convolution with strides=2 and padding=1 // Convolution with strides=2 and padding=1
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
...@@ -201,7 +203,7 @@ TEST(onnx, model_conv2d_strides_padding) ...@@ -201,7 +203,7 @@ TEST(onnx, model_conv2d_strides_padding)
EXPECT_EQ(expected_output, result.front()); EXPECT_EQ(expected_output, result.front());
} }
TEST(onnx, model_conv2d_strides_no_padding) TEST(onnx_${BACKEND_NAME}, model_conv2d_strides_no_padding)
{ {
// Convolution with strides=2 and padding=1 // Convolution with strides=2 and padding=1
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
...@@ -215,7 +217,7 @@ TEST(onnx, model_conv2d_strides_no_padding) ...@@ -215,7 +217,7 @@ TEST(onnx, model_conv2d_strides_no_padding)
EXPECT_EQ(expected_output, result.front()); EXPECT_EQ(expected_output, result.front());
} }
TEST(onnx, model_conv2d_strides_assymetric_padding) TEST(onnx_${BACKEND_NAME}, model_conv2d_strides_assymetric_padding)
{ {
// Convolution with strides=2 and padding=1 // Convolution with strides=2 and padding=1
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
...@@ -230,7 +232,7 @@ TEST(onnx, model_conv2d_strides_assymetric_padding) ...@@ -230,7 +232,7 @@ TEST(onnx, model_conv2d_strides_assymetric_padding)
EXPECT_EQ(expected_output, result.front()); EXPECT_EQ(expected_output, result.front());
} }
TEST(onnx, model_average_pool_2d) TEST(onnx_${BACKEND_NAME}, model_average_pool_2d)
{ {
// Pooling with strides=2 and no padding // Pooling with strides=2 and no padding
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
...@@ -247,12 +249,12 @@ TEST(onnx, model_average_pool_2d) ...@@ -247,12 +249,12 @@ TEST(onnx, model_average_pool_2d)
// (1, 1, 2, 2) // (1, 1, 2, 2)
auto expected_output = test::NDArray<float, 4>({{{{2.5f, 4.5f}, {10.5f, 12.5f}}}}).get_vector(); auto expected_output = test::NDArray<float, 4>({{{{2.5f, 4.5f}, {10.5f, 12.5f}}}}).get_vector();
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_EQ(expected_output, outputs.front()); EXPECT_EQ(expected_output, outputs.front());
} }
TEST(onnx, model_average_pool_2d_pads) TEST(onnx_${BACKEND_NAME}, model_average_pool_2d_pads)
{ {
// Pooling with strides=2 and padding=1 // Pooling with strides=2 and padding=1
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
...@@ -271,12 +273,12 @@ TEST(onnx, model_average_pool_2d_pads) ...@@ -271,12 +273,12 @@ TEST(onnx, model_average_pool_2d_pads)
test::NDArray<float, 4>({{{{0.f, 1.5f, 3.f}, {6.f, 7.5f, 9.f}, {12.f, 13.5f, 15.f}}}}) test::NDArray<float, 4>({{{{0.f, 1.5f, 3.f}, {6.f, 7.5f, 9.f}, {12.f, 13.5f, 15.f}}}})
.get_vector(); .get_vector();
Outputs outputs = execute(function, inputs, "INTERPRETER"); Outputs outputs = execute(function, inputs, "${BACKEND_NAME}");
EXPECT_EQ(expected_output, outputs.front()); EXPECT_EQ(expected_output, outputs.front());
} }
TEST(onnx, model_max_pool_2d_pads) TEST(onnx_${BACKEND_NAME}, model_max_pool_2d_pads)
{ {
// Pooling with strides=2 and padding=1 // Pooling with strides=2 and padding=1
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
...@@ -295,12 +297,12 @@ TEST(onnx, model_max_pool_2d_pads) ...@@ -295,12 +297,12 @@ TEST(onnx, model_max_pool_2d_pads)
test::NDArray<float, 4>({{{{0.f, 2.f, 3.f}, {8.f, 10.f, 11.f}, {12.f, 14.f, 15.f}}}}) test::NDArray<float, 4>({{{{0.f, 2.f, 3.f}, {8.f, 10.f, 11.f}, {12.f, 14.f, 15.f}}}})
.get_vector(); .get_vector();
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_EQ(expected_output, outputs.front()); EXPECT_EQ(expected_output, outputs.front());
} }
TEST(onnx, model_batchnorm_default) TEST(onnx_${BACKEND_NAME}, model_batchnorm_default)
{ {
// Batch Normalization with default parameters // Batch Normalization with default parameters
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
...@@ -326,11 +328,11 @@ TEST(onnx, model_batchnorm_default) ...@@ -326,11 +328,11 @@ TEST(onnx, model_batchnorm_default)
{{{{-0.999995f, 0.f, 0.999995f}}, {{-0.22474074f, 1.f, 2.2247407f}}}}} {{{{-0.999995f, 0.f, 0.999995f}}, {{-0.22474074f, 1.f, 2.2247407f}}}}}
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_relu) TEST(onnx_${BACKEND_NAME}, model_relu)
{ {
// Simple ReLU test // Simple ReLU test
auto function = auto function =
...@@ -339,11 +341,11 @@ TEST(onnx, model_relu) ...@@ -339,11 +341,11 @@ TEST(onnx, model_relu)
Inputs inputs{{-1, -2, 0, 1, 2, 3}}; Inputs inputs{{-1, -2, 0, 1, 2, 3}};
Outputs expected_outputs{{0, 0, 0, 1, 2, 3}}; Outputs expected_outputs{{0, 0, 0, 1, 2, 3}};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_sum) TEST(onnx_${BACKEND_NAME}, model_sum)
{ {
// Simple Sum test // Simple Sum test
auto function = auto function =
...@@ -356,11 +358,11 @@ TEST(onnx, model_sum) ...@@ -356,11 +358,11 @@ TEST(onnx, model_sum)
inputs.emplace_back(std::vector<float>{2.f, 6.f, 6.f}); inputs.emplace_back(std::vector<float>{2.f, 6.f, 6.f});
Outputs expected_outputs{{6.f, 9.f, 12.f}}; Outputs expected_outputs{{6.f, 9.f, 12.f}};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_sum_one_input) TEST(onnx_${BACKEND_NAME}, model_sum_one_input)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/sum_one_input.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/sum_one_input.onnx"));
...@@ -368,11 +370,11 @@ TEST(onnx, model_sum_one_input) ...@@ -368,11 +370,11 @@ TEST(onnx, model_sum_one_input)
// input data shape (3, ) // input data shape (3, )
Inputs inputs{{3.f, 0.f, 2.f}}; Inputs inputs{{3.f, 0.f, 2.f}};
Outputs expected_outputs{{3.f, 0.f, 2.f}}; Outputs expected_outputs{{3.f, 0.f, 2.f}};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_min_two_inputs) TEST(onnx_${BACKEND_NAME}, model_min_two_inputs)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/min_two_inputs.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/min_two_inputs.onnx"));
...@@ -383,11 +385,11 @@ TEST(onnx, model_min_two_inputs) ...@@ -383,11 +385,11 @@ TEST(onnx, model_min_two_inputs)
inputs.emplace_back(std::vector<float>{1.f, 4.f, 4.f}); inputs.emplace_back(std::vector<float>{1.f, 4.f, 4.f});
Outputs expected_outputs{{1.f, 2.f, 1.f}}; Outputs expected_outputs{{1.f, 2.f, 1.f}};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_max) TEST(onnx_${BACKEND_NAME}, model_max)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/max.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/max.onnx"));
...@@ -399,11 +401,11 @@ TEST(onnx, model_max) ...@@ -399,11 +401,11 @@ TEST(onnx, model_max)
inputs.emplace_back(std::vector<float>{2.f, 5.f, 3.f}); inputs.emplace_back(std::vector<float>{2.f, 5.f, 3.f});
Outputs expected_outputs{{3.f, 5.f, 4.f}}; Outputs expected_outputs{{3.f, 5.f, 4.f}};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_mean) TEST(onnx_${BACKEND_NAME}, model_mean)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/mean.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/mean.onnx"));
...@@ -415,11 +417,11 @@ TEST(onnx, model_mean) ...@@ -415,11 +417,11 @@ TEST(onnx, model_mean)
inputs.emplace_back(std::vector<float>{2.f, 6.f, 6.f}); inputs.emplace_back(std::vector<float>{2.f, 6.f, 6.f});
Outputs expected_outputs{{2.f, 3.f, 4.f}}; Outputs expected_outputs{{2.f, 3.f, 4.f}};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_gemm_abc) TEST(onnx_${BACKEND_NAME}, model_gemm_abc)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/gemm_abc.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/gemm_abc.onnx"));
...@@ -445,11 +447,11 @@ TEST(onnx, model_gemm_abc) ...@@ -445,11 +447,11 @@ TEST(onnx, model_gemm_abc)
{{340, 350.5, 361, 371.5}, {862, 890.5, 919, 947.5}, {1384, 1430.5, 1477, 1523.5}}) {{340, 350.5, 361, 371.5}, {862, 890.5, 919, 947.5}, {1384, 1430.5, 1477, 1523.5}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_matmul) TEST(onnx_${BACKEND_NAME}, model_matmul)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/matmul.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/matmul.onnx"));
...@@ -466,11 +468,11 @@ TEST(onnx, model_matmul) ...@@ -466,11 +468,11 @@ TEST(onnx, model_matmul)
Outputs expected_outputs{ Outputs expected_outputs{
test::NDArray<float, 2>({{190, 200, 210}, {470, 496, 522}, {750, 792, 834}}).get_vector()}; test::NDArray<float, 2>({{190, 200, 210}, {470, 496, 522}, {750, 792, 834}}).get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_softmax) TEST(onnx_${BACKEND_NAME}, DISABLED_model_softmax)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/softmax.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/softmax.onnx"));
...@@ -521,11 +523,11 @@ TEST(onnx, model_softmax) ...@@ -521,11 +523,11 @@ TEST(onnx, model_softmax)
6.32120559e-01f}}}) 6.32120559e-01f}}})
.get_vector(); .get_vector();
auto result_vectors = execute(function, inputs, "INTERPRETER"); auto result_vectors = execute(function, inputs, "${BACKEND_NAME}");
EXPECT_TRUE(test::all_close_f(expected_output, result_vectors.front())); EXPECT_TRUE(test::all_close_f(expected_output, result_vectors.front()));
} }
TEST(onnx, model_concat) TEST(onnx_${BACKEND_NAME}, model_concat)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/concat.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/concat.onnx"));
...@@ -537,11 +539,11 @@ TEST(onnx, model_concat) ...@@ -537,11 +539,11 @@ TEST(onnx, model_concat)
Outputs expected_outputs{test::NDArray<float, 1>({1, 2, 3, 4}).get_vector()}; Outputs expected_outputs{test::NDArray<float, 1>({1, 2, 3, 4}).get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_flatten) TEST(onnx_${BACKEND_NAME}, model_flatten)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/flatten.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/flatten.onnx"));
...@@ -553,11 +555,11 @@ TEST(onnx, model_flatten) ...@@ -553,11 +555,11 @@ TEST(onnx, model_flatten)
Outputs expected_outputs{test::NDArray<float, 3>({{{1, 2, 3, 4}, {5, 6, 7, 8}}}).get_vector()}; Outputs expected_outputs{test::NDArray<float, 3>({{{1, 2, 3, 4}, {5, 6, 7, 8}}}).get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_sub) TEST(onnx_${BACKEND_NAME}, model_sub)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/sub.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/sub.onnx"));
...@@ -569,11 +571,11 @@ TEST(onnx, model_sub) ...@@ -569,11 +571,11 @@ TEST(onnx, model_sub)
auto expected_output = test::NDArray<float, 3>({{{-3, -3, -4}}}).get_vector(); auto expected_output = test::NDArray<float, 3>({{{-3, -3, -4}}}).get_vector();
auto result_vectors = execute(function, inputs, "INTERPRETER"); auto result_vectors = execute(function, inputs, "${BACKEND_NAME}");
EXPECT_TRUE(test::all_close_f(expected_output, result_vectors.front())); EXPECT_TRUE(test::all_close_f(expected_output, result_vectors.front()));
} }
TEST(onnx, model_unsqueeze) TEST(onnx_${BACKEND_NAME}, model_unsqueeze)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/unsqueeze.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/unsqueeze.onnx"));
...@@ -592,11 +594,11 @@ TEST(onnx, model_unsqueeze) ...@@ -592,11 +594,11 @@ TEST(onnx, model_unsqueeze)
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}}}) {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
} }
TEST(onnx, model_squeeze) TEST(onnx_${BACKEND_NAME}, model_squeeze)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/squeeze_duplicate_axes.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/squeeze_duplicate_axes.onnx"));
...@@ -611,11 +613,11 @@ TEST(onnx, model_squeeze) ...@@ -611,11 +613,11 @@ TEST(onnx, model_squeeze)
test::NDArray<float, 2>({{1.0f, 2.0f}, {3.0f, 4.0f}, {5.0f, 6.0f}, {7.0f, 8.0f}}) test::NDArray<float, 2>({{1.0f, 2.0f}, {3.0f, 4.0f}, {5.0f, 6.0f}, {7.0f, 8.0f}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
} }
TEST(onnx, model_div) TEST(onnx_${BACKEND_NAME}, model_div)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/div.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/div.onnx"));
...@@ -627,11 +629,11 @@ TEST(onnx, model_div) ...@@ -627,11 +629,11 @@ TEST(onnx, model_div)
auto expected_output = test::NDArray<float, 3>({{{1, 0.5, 0.25}}}).get_vector(); auto expected_output = test::NDArray<float, 3>({{{1, 0.5, 0.25}}}).get_vector();
auto result_vectors = execute(function, inputs, "INTERPRETER"); auto result_vectors = execute(function, inputs, "${BACKEND_NAME}");
EXPECT_TRUE(test::all_close_f(expected_output, result_vectors.front())); EXPECT_TRUE(test::all_close_f(expected_output, result_vectors.front()));
} }
TEST(onnx, model_add_bcast) TEST(onnx_${BACKEND_NAME}, model_add_bcast)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/add_bcast.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/add_bcast.onnx"));
...@@ -652,11 +654,11 @@ TEST(onnx, model_add_bcast) ...@@ -652,11 +654,11 @@ TEST(onnx, model_add_bcast)
{{2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}}}}) {{2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}}}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
} }
TEST(onnx, model_reshape_reduced_dims) TEST(onnx_${BACKEND_NAME}, model_reshape_reduced_dims)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_reduced_dims.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_reduced_dims.onnx"));
...@@ -672,11 +674,11 @@ TEST(onnx, model_reshape_reduced_dims) ...@@ -672,11 +674,11 @@ TEST(onnx, model_reshape_reduced_dims)
{12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}}) {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_reshape_reordered_dims) TEST(onnx_${BACKEND_NAME}, model_reshape_reordered_dims)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_reordered_dims.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_reordered_dims.onnx"));
...@@ -693,11 +695,11 @@ TEST(onnx, model_reshape_reordered_dims) ...@@ -693,11 +695,11 @@ TEST(onnx, model_reshape_reordered_dims)
{{18, 19, 20}, {21, 22, 23}}}) {{18, 19, 20}, {21, 22, 23}}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_reshape_extended_dims) TEST(onnx_${BACKEND_NAME}, model_reshape_extended_dims)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_extended_dims.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_extended_dims.onnx"));
...@@ -713,11 +715,11 @@ TEST(onnx, model_reshape_extended_dims) ...@@ -713,11 +715,11 @@ TEST(onnx, model_reshape_extended_dims)
{{{16, 17}, {18, 19}}, {{20, 21}, {22, 23}}}}) {{{16, 17}, {18, 19}}, {{20, 21}, {22, 23}}}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_reshape_single_dim) TEST(onnx_${BACKEND_NAME}, model_reshape_single_dim)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_single_dim.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_single_dim.onnx"));
...@@ -733,11 +735,11 @@ TEST(onnx, model_reshape_single_dim) ...@@ -733,11 +735,11 @@ TEST(onnx, model_reshape_single_dim)
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}) {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_reshape_negative_dim) TEST(onnx_${BACKEND_NAME}, model_reshape_negative_dim)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_negative_dim.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_negative_dim.onnx"));
...@@ -756,11 +758,11 @@ TEST(onnx, model_reshape_negative_dim) ...@@ -756,11 +758,11 @@ TEST(onnx, model_reshape_negative_dim)
{{20, 21}, {22, 23}}}) {{20, 21}, {22, 23}}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_reshape_negative_with_zero_dim) TEST(onnx_${BACKEND_NAME}, model_reshape_negative_with_zero_dim)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_negative_with_zero_dims.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_negative_with_zero_dims.onnx"));
...@@ -776,11 +778,11 @@ TEST(onnx, model_reshape_negative_with_zero_dim) ...@@ -776,11 +778,11 @@ TEST(onnx, model_reshape_negative_with_zero_dim)
{{12, 13}, {14, 15}, {16, 17}, {18, 19}, {20, 21}, {22, 23}}}) {{12, 13}, {14, 15}, {16, 17}, {18, 19}, {20, 21}, {22, 23}}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_reshape_output_shape_as_input) TEST(onnx_${BACKEND_NAME}, model_reshape_output_shape_as_input)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_output_shape_as_input.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_output_shape_as_input.onnx"));
...@@ -796,11 +798,11 @@ TEST(onnx, model_reshape_output_shape_as_input) ...@@ -796,11 +798,11 @@ TEST(onnx, model_reshape_output_shape_as_input)
{{12, 13}, {14, 15}, {16, 17}, {18, 19}, {20, 21}, {22, 23}}}) {{12, 13}, {14, 15}, {16, 17}, {18, 19}, {20, 21}, {22, 23}}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_reduce_log_sum) TEST(onnx_${BACKEND_NAME}, model_reduce_log_sum)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_log_sum.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_log_sum.onnx"));
...@@ -813,11 +815,11 @@ TEST(onnx, model_reduce_log_sum) ...@@ -813,11 +815,11 @@ TEST(onnx, model_reduce_log_sum)
// output data shape (1,) // output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{2.77258872f}}}}).get_vector()}; Outputs expected_outputs{test::NDArray<float, 4>({{{{2.77258872f}}}}).get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_reduce_log_sum_exp) TEST(onnx_${BACKEND_NAME}, model_reduce_log_sum_exp)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_log_sum_exp.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_log_sum_exp.onnx"));
...@@ -830,11 +832,11 @@ TEST(onnx, model_reduce_log_sum_exp) ...@@ -830,11 +832,11 @@ TEST(onnx, model_reduce_log_sum_exp)
// output data shape (1,) // output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{3.77258872f}}}}).get_vector()}; Outputs expected_outputs{test::NDArray<float, 4>({{{{3.77258872f}}}}).get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_reduce_l1) TEST(onnx_${BACKEND_NAME}, model_reduce_l1)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_l1.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_l1.onnx"));
...@@ -847,11 +849,11 @@ TEST(onnx, model_reduce_l1) ...@@ -847,11 +849,11 @@ TEST(onnx, model_reduce_l1)
// output data shape (1,) // output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{16}}}}).get_vector()}; Outputs expected_outputs{test::NDArray<float, 4>({{{{16}}}}).get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_reduce_l2) TEST(onnx_${BACKEND_NAME}, model_reduce_l2)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_l2.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_l2.onnx"));
...@@ -864,11 +866,11 @@ TEST(onnx, model_reduce_l2) ...@@ -864,11 +866,11 @@ TEST(onnx, model_reduce_l2)
// output data shape (1,) // output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{4}}}}).get_vector()}; Outputs expected_outputs{test::NDArray<float, 4>({{{{4}}}}).get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_reduce_max) TEST(onnx_${BACKEND_NAME}, model_reduce_max)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_max.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_max.onnx"));
...@@ -881,11 +883,11 @@ TEST(onnx, model_reduce_max) ...@@ -881,11 +883,11 @@ TEST(onnx, model_reduce_max)
// output data shape (1,) // output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{16}}}}).get_vector()}; Outputs expected_outputs{test::NDArray<float, 4>({{{{16}}}}).get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_reduce_mean) TEST(onnx_${BACKEND_NAME}, model_reduce_mean)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_mean.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_mean.onnx"));
...@@ -898,11 +900,11 @@ TEST(onnx, model_reduce_mean) ...@@ -898,11 +900,11 @@ TEST(onnx, model_reduce_mean)
// output data shape (1,) // output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{1}}}}).get_vector()}; Outputs expected_outputs{test::NDArray<float, 4>({{{{1}}}}).get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_reduce_min) TEST(onnx_${BACKEND_NAME}, model_reduce_min)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_min.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_min.onnx"));
...@@ -915,11 +917,11 @@ TEST(onnx, model_reduce_min) ...@@ -915,11 +917,11 @@ TEST(onnx, model_reduce_min)
// output data shape (1,) // output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{1}}}}).get_vector()}; Outputs expected_outputs{test::NDArray<float, 4>({{{{1}}}}).get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_reduce_prod) TEST(onnx_${BACKEND_NAME}, model_reduce_prod)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_prod.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_prod.onnx"));
...@@ -932,11 +934,11 @@ TEST(onnx, model_reduce_prod) ...@@ -932,11 +934,11 @@ TEST(onnx, model_reduce_prod)
// output data shape (1,) // output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{1}}}}).get_vector()}; Outputs expected_outputs{test::NDArray<float, 4>({{{{1}}}}).get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_reduce_sum) TEST(onnx_${BACKEND_NAME}, model_reduce_sum)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_sum.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_sum.onnx"));
...@@ -949,11 +951,11 @@ TEST(onnx, model_reduce_sum) ...@@ -949,11 +951,11 @@ TEST(onnx, model_reduce_sum)
// output data shape (1,) // output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{16}}}}).get_vector()}; Outputs expected_outputs{test::NDArray<float, 4>({{{{16}}}}).get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_reduce_sum_square) TEST(onnx_${BACKEND_NAME}, model_reduce_sum_square)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_sum_square.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_sum_square.onnx"));
...@@ -966,11 +968,11 @@ TEST(onnx, model_reduce_sum_square) ...@@ -966,11 +968,11 @@ TEST(onnx, model_reduce_sum_square)
// output data shape (1,) // output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{16}}}}).get_vector()}; Outputs expected_outputs{test::NDArray<float, 4>({{{{16}}}}).get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_shape) TEST(onnx_${BACKEND_NAME}, model_shape)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/shape.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/shape.onnx"));
...@@ -985,11 +987,11 @@ TEST(onnx, model_shape) ...@@ -985,11 +987,11 @@ TEST(onnx, model_shape)
std::vector<std::vector<int64_t>> expected_output{{3, 4, 5}}; std::vector<std::vector<int64_t>> expected_output{{3, 4, 5}};
std::vector<std::vector<int64_t>> outputs = std::vector<std::vector<int64_t>> outputs =
execute<float, int64_t>(function, inputs, "INTERPRETER"); execute<float, int64_t>(function, inputs, "${BACKEND_NAME}");
EXPECT_TRUE(test::all_close(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close(expected_output.front(), outputs.front()));
} }
TEST(onnx, model_elu) TEST(onnx_${BACKEND_NAME}, model_elu)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/elu.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/elu.onnx"));
...@@ -1032,11 +1034,11 @@ TEST(onnx, model_elu) ...@@ -1032,11 +1034,11 @@ TEST(onnx, model_elu)
{2, 2, 2, 2, 2}}}) {2, 2, 2, 2, 2}}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
} }
TEST(onnx, model_leaky_relu) TEST(onnx_${BACKEND_NAME}, model_leaky_relu)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/leaky_relu.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/leaky_relu.onnx"));
...@@ -1063,11 +1065,11 @@ TEST(onnx, model_leaky_relu) ...@@ -1063,11 +1065,11 @@ TEST(onnx, model_leaky_relu)
{2, 2, 2, 2, 2}}}) {2, 2, 2, 2, 2}}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
} }
TEST(onnx, prelu) TEST(onnx_${BACKEND_NAME}, prelu)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/prelu.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/prelu.onnx"));
...@@ -1093,11 +1095,11 @@ TEST(onnx, prelu) ...@@ -1093,11 +1095,11 @@ TEST(onnx, prelu)
{{1, 1, 1, 1, 1}, {0, -1, 0, -1, 0}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}}) {{1, 1, 1, 1, 1}, {0, -1, 0, -1, 0}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
} }
TEST(onnx, model_selu) TEST(onnx_${BACKEND_NAME}, model_selu)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/selu.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/selu.onnx"));
...@@ -1134,11 +1136,11 @@ TEST(onnx, model_selu) ...@@ -1134,11 +1136,11 @@ TEST(onnx, model_selu)
{6, 6, 6, 6, 6}}}) {6, 6, 6, 6, 6}}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
} }
TEST(onnx, model_sigmoid) TEST(onnx_${BACKEND_NAME}, model_sigmoid)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/sigmoid.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/sigmoid.onnx"));
...@@ -1209,11 +1211,11 @@ TEST(onnx, model_sigmoid) ...@@ -1209,11 +1211,11 @@ TEST(onnx, model_sigmoid)
0.880797077977882f}}}) 0.880797077977882f}}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
} }
TEST(onnx, model_tanh) TEST(onnx_${BACKEND_NAME}, model_tanh)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/tanh.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/tanh.onnx"));
...@@ -1284,11 +1286,11 @@ TEST(onnx, model_tanh) ...@@ -1284,11 +1286,11 @@ TEST(onnx, model_tanh)
0.964027580075817f}}}) 0.964027580075817f}}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
} }
TEST(onnx, model_thresholded_relu) TEST(onnx_${BACKEND_NAME}, model_thresholded_relu)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/thresholded_relu.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/thresholded_relu.onnx"));
...@@ -1308,11 +1310,11 @@ TEST(onnx, model_thresholded_relu) ...@@ -1308,11 +1310,11 @@ TEST(onnx, model_thresholded_relu)
{{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}}) {{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
} }
TEST(onnx, model_unsupported_op) TEST(onnx_${BACKEND_NAME}, model_unsupported_op)
{ {
try try
{ {
...@@ -1333,7 +1335,7 @@ TEST(onnx, model_unsupported_op) ...@@ -1333,7 +1335,7 @@ TEST(onnx, model_unsupported_op)
} }
} }
TEST(onnx, model_custom_op) TEST(onnx_${BACKEND_NAME}, model_custom_op)
{ {
onnx_import::register_operator( onnx_import::register_operator(
"AddQ", 1, "com.intel.ai", [](const onnx_import::Node& node) -> NodeVector { "AddQ", 1, "com.intel.ai", [](const onnx_import::Node& node) -> NodeVector {
...@@ -1347,11 +1349,11 @@ TEST(onnx, model_custom_op) ...@@ -1347,11 +1349,11 @@ TEST(onnx, model_custom_op)
Inputs inputs{{1, 2, 3, 4}}; Inputs inputs{{1, 2, 3, 4}};
Outputs expected_outputs{{3, 6, 9, 12}}; Outputs expected_outputs{{3, 6, 9, 12}};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_custom_op_default_domain) TEST(onnx_${BACKEND_NAME}, model_custom_op_default_domain)
{ {
onnx_import::register_operator( onnx_import::register_operator(
"AddQ", 1, "com.intel.ai", [](const onnx_import::Node& node) -> NodeVector { "AddQ", 1, "com.intel.ai", [](const onnx_import::Node& node) -> NodeVector {
...@@ -1365,11 +1367,11 @@ TEST(onnx, model_custom_op_default_domain) ...@@ -1365,11 +1367,11 @@ TEST(onnx, model_custom_op_default_domain)
Inputs inputs{{1, 2, 3, 4}}; Inputs inputs{{1, 2, 3, 4}};
Outputs expected_outputs{{3, 6, 9, 12}}; Outputs expected_outputs{{3, 6, 9, 12}};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
} }
TEST(onnx, model_conv2d_dilation_assymetric_pads_strides) TEST(onnx_${BACKEND_NAME}, model_conv2d_dilation_assymetric_pads_strides)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/conv2d_dilation_assym_pads_strides.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/conv2d_dilation_assym_pads_strides.onnx"));
...@@ -1405,11 +1407,11 @@ TEST(onnx, model_conv2d_dilation_assymetric_pads_strides) ...@@ -1405,11 +1407,11 @@ TEST(onnx, model_conv2d_dilation_assymetric_pads_strides)
{{-0.10154513269662857f, -0.13448859751224518f}}}}) {{-0.10154513269662857f, -0.13448859751224518f}}}})
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
} }
TEST(onnx, model_conv3d_bias) TEST(onnx_${BACKEND_NAME}, model_conv3d_bias)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/conv3d_bias.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/conv3d_bias.onnx"));
...@@ -1519,11 +1521,11 @@ TEST(onnx, model_conv3d_bias) ...@@ -1519,11 +1521,11 @@ TEST(onnx, model_conv3d_bias)
-0.39770257472991943f, -0.45317384600639343f, -0.5598302483558655f, -0.2542789578437805f, -0.39770257472991943f, -0.45317384600639343f, -0.5598302483558655f, -0.2542789578437805f,
-0.5359901785850525f, -0.48090484738349915f, -0.38603779673576355f, -0.4991581439971924f}}; -0.5359901785850525f, -0.48090484738349915f, -0.38603779673576355f, -0.4991581439971924f}};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
} }
TEST(onnx, model_matmul_vec_ten3d) TEST(onnx_${BACKEND_NAME}, model_matmul_vec_ten3d)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/matmul_vec_ten3d.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/matmul_vec_ten3d.onnx"));
...@@ -1535,11 +1537,11 @@ TEST(onnx, model_matmul_vec_ten3d) ...@@ -1535,11 +1537,11 @@ TEST(onnx, model_matmul_vec_ten3d)
Outputs expected_output{test::NDArray<float, 2>{{1.f}, {3.f}, {5.f}}}; Outputs expected_output{test::NDArray<float, 2>{{1.f}, {3.f}, {5.f}}};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
} }
TEST(onnx, model_softplus) TEST(onnx_${BACKEND_NAME}, DISABLED_model_softplus)
{ {
auto function = auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/softplus.onnx")); onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/softplus.onnx"));
...@@ -1578,7 +1580,7 @@ TEST(onnx, model_softplus) ...@@ -1578,7 +1580,7 @@ TEST(onnx, model_softplus)
std::transform(std::begin(input), std::end(input), std::back_inserter(output), softplus_impl); std::transform(std::begin(input), std::end(input), std::back_inserter(output), softplus_impl);
Outputs expected_output{output}; Outputs expected_output{output};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
inputs.clear(); inputs.clear();
...@@ -1599,7 +1601,7 @@ TEST(onnx, model_softplus) ...@@ -1599,7 +1601,7 @@ TEST(onnx, model_softplus)
std::numeric_limits<float>::infinity(), std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity()}); std::numeric_limits<float>::infinity()});
input = inputs.back(); input = inputs.back();
outputs = execute(function, inputs, "INTERPRETER"); outputs = execute(function, inputs, "${BACKEND_NAME}");
for (float v : outputs.front()) for (float v : outputs.front())
{ {
...@@ -1607,7 +1609,7 @@ TEST(onnx, model_softplus) ...@@ -1607,7 +1609,7 @@ TEST(onnx, model_softplus)
} }
} }
TEST(onnx, model_sum_opset8) TEST(onnx_${BACKEND_NAME}, model_sum_opset8)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/sum_opset8.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/sum_opset8.onnx"));
...@@ -1625,11 +1627,11 @@ TEST(onnx, model_sum_opset8) ...@@ -1625,11 +1627,11 @@ TEST(onnx, model_sum_opset8)
{{311.0f, 312.0f, 313.0f}, {321.0f, 322.0f, 323.0f}, {331.0f, 332.0f, 333.0f}}} {{311.0f, 312.0f, 313.0f}, {321.0f, 322.0f, 323.0f}, {331.0f, 332.0f, 333.0f}}}
.get_vector()}; .get_vector()};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
} }
TEST(onnx, model_conv_transpose_w_groups) TEST(onnx_${BACKEND_NAME}, model_conv_transpose_w_groups)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/conv_transpose_w_groups.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/conv_transpose_w_groups.onnx"));
...@@ -1644,11 +1646,11 @@ TEST(onnx, model_conv_transpose_w_groups) ...@@ -1644,11 +1646,11 @@ TEST(onnx, model_conv_transpose_w_groups)
Outputs expected_output{ Outputs expected_output{
std::vector<float>{28.f, 34.f, 252.f, 274.f, 732.f, 770.f, 1468.f, 1522.f}}; std::vector<float>{28.f, 34.f, 252.f, 274.f, 732.f, 770.f, 1468.f, 1522.f}};
Outputs outputs{execute(function, inputs, "INTERPRETER")}; Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
} }
TEST(onnx, model_argmax_int32) TEST(onnx_${BACKEND_NAME}, model_argmax_int32)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/argmax_int32.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/argmax_int32.onnx"));
...@@ -1660,11 +1662,11 @@ TEST(onnx, model_argmax_int32) ...@@ -1660,11 +1662,11 @@ TEST(onnx, model_argmax_int32)
std::vector<std::int64_t>{1, 1, 1, 1, 1, 1}}; std::vector<std::int64_t>{1, 1, 1, 1, 1, 1}};
std::vector<std::vector<std::int64_t>> outputs{ std::vector<std::vector<std::int64_t>> outputs{
execute<std::int32_t, std::int64_t>(function, inputs, "CPU")}; execute<std::int32_t, std::int64_t>(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close(expected_output.front(), outputs.front()));
} }
TEST(onnx, model_argmin_int32) TEST(onnx_${BACKEND_NAME}, model_argmin_int32)
{ {
auto function = onnx_import::import_onnx_model( auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/argmin_int32.onnx")); file_util::path_join(SERIALIZED_ZOO, "onnx/argmin_int32.onnx"));
...@@ -1675,6 +1677,37 @@ TEST(onnx, model_argmin_int32) ...@@ -1675,6 +1677,37 @@ TEST(onnx, model_argmin_int32)
std::vector<std::vector<std::int64_t>> expected_output{std::vector<std::int64_t>{0, 0, 0, 0}}; std::vector<std::vector<std::int64_t>> expected_output{std::vector<std::int64_t>{0, 0, 0, 0}};
std::vector<std::vector<std::int64_t>> outputs{ std::vector<std::vector<std::int64_t>> outputs{
execute<std::int32_t, std::int64_t>(function, inputs, "CPU")}; execute<std::int32_t, std::int64_t>(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close(expected_output.front(), outputs.front())); EXPECT_TRUE(test::all_close(expected_output.front(), outputs.front()));
} }
TEST(onnx_${BACKEND_NAME}, is_op_supported)
{
// Simple case
EXPECT_TRUE(onnx_import::is_operator_supported("Sum", 1, "ai.onnx"));
// With fallback
EXPECT_TRUE(onnx_import::is_operator_supported("Sum", 100, "ai.onnx"));
// Different opset versions
EXPECT_TRUE(onnx_import::is_operator_supported("Add", 1, "ai.onnx"));
EXPECT_TRUE(onnx_import::is_operator_supported("Add", 7, "ai.onnx"));
// Default domain name
EXPECT_TRUE(onnx_import::is_operator_supported("Sum", 1));
// Unregistered operator
EXPECT_FALSE(onnx_import::is_operator_supported("DummyOp", 1));
EXPECT_FALSE(onnx_import::is_operator_supported("DummyOp", 1, "ai.onnx"));
EXPECT_FALSE(onnx_import::is_operator_supported("DummyOp", 10, "ai.onnx"));
// Operator with bad domain name
EXPECT_FALSE(onnx_import::is_operator_supported("Sum", 1, "bad.domain"));
// Registered custom operator
onnx_import::register_operator(
"AddQ", 1, "com.intel.ai", [](const onnx_import::Node& node) -> NodeVector {
NodeVector ng_inputs{node.get_ng_inputs()};
return {std::make_shared<ngraph::op::Add>(ng_inputs.at(0), ng_inputs.at(1))};
});
EXPECT_TRUE(onnx_import::is_operator_supported("AddQ", 1, "com.intel.ai"));
}
...@@ -163,3 +163,43 @@ TEST(reshape_sinking, nasnet_pooladd) ...@@ -163,3 +163,43 @@ TEST(reshape_sinking, nasnet_pooladd)
size_t before_after = count_ops_of_type<op::Reshape>(func); size_t before_after = count_ops_of_type<op::Reshape>(func);
ASSERT_LE(before_after, before_count); ASSERT_LE(before_after, before_count);
} }
TEST(reshape_sinking, slice_pad)
{
Shape shape_a{100, 8, 8, 1};
AxisVector to_nhwc{0, 2, 3, 1};
AxisVector to_nchw{0, 3, 1, 2};
auto A = make_shared<op::Parameter>(element::f32, shape_a);
auto pad_value = op::Constant::create<float>(element::f32, Shape{}, std::vector<float>{0.0f});
Shape padding_below{0, 0, 0, 0};
Shape padding_above{0, 1, 1, 0};
Shape padding_interior{0, 0, 0, 0};
auto reshape1 = make_shared<op::Reshape>(A, to_nchw, Shape{100, 1, 8, 8});
auto maxpool =
make_shared<op::MaxPool>(reshape1, Shape{1, 1}, Strides{2, 2}, Shape{0, 0}, Shape{0, 0});
auto reshape2 = make_shared<op::Reshape>(maxpool, to_nhwc, Shape{100, 4, 4, 1});
auto pad =
make_shared<op::Pad>(reshape2, pad_value, padding_below, padding_above, padding_interior);
auto slice = make_shared<op::Slice>(
pad, Coordinate{0, 1, 1, 0}, Coordinate{100, 5, 5, 1}, Strides{1, 1, 1, 1});
auto reshape3 = make_shared<op::Reshape>(slice, to_nchw, Shape{100, 1, 4, 4});
auto avgpool = make_shared<op::AvgPool>(reshape3, Shape{1, 1}, Strides{2, 2});
auto reshape4 = make_shared<op::Reshape>(avgpool, to_nhwc, Shape{100, 1, 2, 2});
auto f = make_shared<Function>(reshape4, ParameterVector{A});
pass::Manager pass_manager;
size_t before_count = count_ops_of_type<op::Reshape>(f);
pass_manager.register_pass<pass::VisualizeTree>("before.pdf");
pass_manager.register_pass<pass::ReshapeSinking>();
pass_manager.register_pass<pass::ReshapeElimination>();
pass_manager.register_pass<pass::CommonSubexpressionElimination>();
pass_manager.register_pass<pass::VisualizeTree>("after.pdf");
pass_manager.run_passes(f);
size_t before_after = count_ops_of_type<op::Reshape>(f);
ASSERT_LE(before_after, before_count);
}
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