Remove deprecated Any op from nGraph (#2719)
This commit is contained in:
parent
8002b16eb2
commit
83670dd5cb
@ -1,61 +0,0 @@
|
||||
//*****************************************************************************
|
||||
// Copyright 2017-2020 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//*****************************************************************************
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ngraph/op/util/logical_reduction.hpp"
|
||||
|
||||
namespace ngraph
|
||||
{
|
||||
namespace op
|
||||
{
|
||||
namespace v0
|
||||
{
|
||||
/// \brief Logical "any" reduction operation.
|
||||
class NGRAPH_DEPRECATED(
|
||||
"This operation is deprecated and will be removed soon. Please don't use it.")
|
||||
NGRAPH_API Any : public util::LogicalReduction
|
||||
{
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
public:
|
||||
static constexpr NodeTypeInfo type_info{"Any", 0};
|
||||
const NodeTypeInfo& get_type_info() const override { return type_info; }
|
||||
/// \brief Constructs an "any" reduction operation.
|
||||
Any() = default;
|
||||
/// \brief Constructs an "any" reduction operation.
|
||||
///
|
||||
/// \param arg The tensor to be reduced.
|
||||
/// \param reduction_axes The axis positions (0-based) to be eliminated.
|
||||
Any(const Output<Node>& arg, const AxisSet& reduction_axes);
|
||||
/// \brief Constructs an "any" reduction operation.
|
||||
///
|
||||
/// \param arg The tensor to be reduced.
|
||||
/// \param reduction_axes The axis positions (0-based) to be eliminated.
|
||||
Any(const Output<Node>& arg, const Output<Node>& reduction_axes);
|
||||
|
||||
virtual std::shared_ptr<Node>
|
||||
clone_with_new_inputs(const OutputVector& new_args) const override;
|
||||
bool visit_attributes(AttributeVisitor& visitor) override { return true; }
|
||||
/// \return The default value for Any.
|
||||
virtual std::shared_ptr<Node> get_default_value() const override;
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
};
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
using v0::Any;
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ NGRAPH_OP(Acos, ngraph::op::v0, 0)
|
||||
NGRAPH_OP(Acosh, ngraph::op::v3, 3)
|
||||
NGRAPH_OP(Add, ngraph::op::v0, 0)
|
||||
NGRAPH_OP(Add, ngraph::op::v1, 1)
|
||||
NGRAPH_OP(Any, ngraph::op::v0, 0)
|
||||
NGRAPH_OP(Asin, ngraph::op::v0, 0)
|
||||
NGRAPH_OP(Asinh, ngraph::op::v3, 3)
|
||||
NGRAPH_OP(Atan, ngraph::op::v0, 0)
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "ngraph/op/acosh.hpp"
|
||||
#include "ngraph/op/add.hpp"
|
||||
#include "ngraph/op/and.hpp"
|
||||
#include "ngraph/op/any.hpp"
|
||||
#include "ngraph/op/asin.hpp"
|
||||
#include "ngraph/op/asinh.hpp"
|
||||
#include "ngraph/op/assign.hpp"
|
||||
|
@ -1,55 +0,0 @@
|
||||
//*****************************************************************************
|
||||
// Copyright 2017-2020 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//*****************************************************************************
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "ngraph/coordinate_transform.hpp"
|
||||
#include "ngraph/shape_util.hpp"
|
||||
|
||||
namespace ngraph
|
||||
{
|
||||
namespace runtime
|
||||
{
|
||||
namespace reference
|
||||
{
|
||||
static inline void any(const char* arg,
|
||||
char* out,
|
||||
const Shape& in_shape,
|
||||
const AxisSet& reduction_axes,
|
||||
bool keep_dims)
|
||||
{
|
||||
CoordinateTransform output_transform(reduce(in_shape, reduction_axes, keep_dims));
|
||||
|
||||
for (const Coordinate& output_coord : output_transform)
|
||||
{
|
||||
out[output_transform.index(output_coord)] = 0;
|
||||
}
|
||||
|
||||
CoordinateTransform input_transform(in_shape);
|
||||
|
||||
for (const Coordinate& input_coord : input_transform)
|
||||
{
|
||||
Coordinate output_coord = reduce(input_coord, reduction_axes, keep_dims);
|
||||
out[output_transform.index(output_coord)] =
|
||||
out[output_transform.index(output_coord)] ||
|
||||
arg[input_transform.index(input_coord)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -19,7 +19,6 @@
|
||||
#include <cmath>
|
||||
|
||||
#include "ngraph/coordinate_transform.hpp"
|
||||
#include "ngraph/runtime/reference/any.hpp"
|
||||
#include "ngraph/shape_util.hpp"
|
||||
|
||||
namespace ngraph
|
||||
@ -59,7 +58,23 @@ namespace ngraph
|
||||
const AxisSet& reduction_axes,
|
||||
bool keep_dims)
|
||||
{
|
||||
runtime::reference::any(arg, out, input_shape, reduction_axes, keep_dims);
|
||||
CoordinateTransform output_transform(
|
||||
reduce(input_shape, reduction_axes, keep_dims));
|
||||
|
||||
for (const Coordinate& output_coord : output_transform)
|
||||
{
|
||||
out[output_transform.index(output_coord)] = 0;
|
||||
}
|
||||
|
||||
CoordinateTransform input_transform(input_shape);
|
||||
|
||||
for (const Coordinate& input_coord : input_transform)
|
||||
{
|
||||
Coordinate output_coord = reduce(input_coord, reduction_axes, keep_dims);
|
||||
out[output_transform.index(output_coord)] =
|
||||
out[output_transform.index(output_coord)] ||
|
||||
arg[input_transform.index(input_coord)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,48 +0,0 @@
|
||||
//*****************************************************************************
|
||||
// Copyright 2017-2020 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//*****************************************************************************
|
||||
|
||||
#include "ngraph/op/any.hpp"
|
||||
#include "ngraph/graph_util.hpp"
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
|
||||
using namespace std;
|
||||
using namespace ngraph;
|
||||
|
||||
constexpr NodeTypeInfo op::Any::type_info;
|
||||
|
||||
op::Any::Any(const Output<Node>& arg, const AxisSet& reduction_axes)
|
||||
: LogicalReduction(arg, reduction_axes)
|
||||
{
|
||||
constructor_validate_and_infer_types();
|
||||
}
|
||||
|
||||
op::Any::Any(const Output<Node>& arg, const Output<Node>& reduction_axes)
|
||||
: LogicalReduction(arg, reduction_axes)
|
||||
{
|
||||
constructor_validate_and_infer_types();
|
||||
}
|
||||
|
||||
shared_ptr<Node> op::Any::clone_with_new_inputs(const OutputVector& new_args) const
|
||||
{
|
||||
check_new_args_count(this, new_args);
|
||||
return make_shared<Any>(new_args.at(0), new_args.at(1));
|
||||
}
|
||||
|
||||
shared_ptr<Node> op::Any::get_default_value() const
|
||||
{
|
||||
return ngraph::make_constant_from_string("0", get_element_type(), get_shape());
|
||||
}
|
@ -16,10 +16,8 @@
|
||||
|
||||
#include "constant_folding.hpp"
|
||||
#include "ngraph/log.hpp"
|
||||
#include "ngraph/op/any.hpp"
|
||||
#include "ngraph/op/reduce_logical_and.hpp"
|
||||
#include "ngraph/op/reduce_logical_or.hpp"
|
||||
#include "ngraph/runtime/reference/any.hpp"
|
||||
#include "ngraph/runtime/reference/logical_reduction.hpp"
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
@ -33,15 +31,7 @@ static shared_ptr<op::Constant> fold_constant_logical_reduction(shared_ptr<op::C
|
||||
runtime::AlignedBuffer buffer(shape_size(reduction_node->get_shape()) * sizeof(char));
|
||||
char* data_ptr = buffer.get_ptr<char>();
|
||||
|
||||
if (auto any = as_type_ptr<::ngraph::op::Any>(reduction_node))
|
||||
{
|
||||
runtime::reference::any(constant->get_data_ptr<char>(),
|
||||
data_ptr,
|
||||
reduction_node->get_input_shape(0),
|
||||
any->get_reduction_axes(),
|
||||
false);
|
||||
}
|
||||
else if (auto reduce_and = as_type_ptr<::ngraph::op::v1::ReduceLogicalAnd>(reduction_node))
|
||||
if (auto reduce_and = as_type_ptr<::ngraph::op::v1::ReduceLogicalAnd>(reduction_node))
|
||||
{
|
||||
const auto reduction_axes = reduce_and->get_reduction_axes();
|
||||
const auto input_shape = reduce_and->get_input_shape(0);
|
||||
@ -78,9 +68,8 @@ void pass::ConstantFolding::construct_constant_logical_reduction()
|
||||
auto constant_axes_label =
|
||||
make_shared<pattern::op::Label>(element::i64, Shape{2}, pattern::has_class<op::Constant>());
|
||||
auto is_supported_reduction = [](std::shared_ptr<Node> n) {
|
||||
return (pattern::has_class<::ngraph::op::Any>()(n) ||
|
||||
pattern::has_class<::ngraph::op::v1::ReduceLogicalAnd>()(n) ||
|
||||
pattern::has_class<::ngraph::op::v1::ReduceLogicalOr>()(n));
|
||||
return pattern::has_class<::ngraph::op::v1::ReduceLogicalAnd>()(n) ||
|
||||
pattern::has_class<::ngraph::op::v1::ReduceLogicalOr>()(n);
|
||||
};
|
||||
auto reduction =
|
||||
std::make_shared<pattern::op::Any>(element::i32,
|
||||
|
@ -96,7 +96,6 @@ set(SRC
|
||||
shape.cpp
|
||||
specialize_function.cpp
|
||||
tensor.cpp
|
||||
type_prop/any.cpp
|
||||
type_prop/assign.cpp
|
||||
type_prop/avg_pool.cpp
|
||||
type_prop/batch_norm.cpp
|
||||
@ -260,7 +259,6 @@ set(MULTI_TEST_SRC
|
||||
backend/acosh.in.cpp
|
||||
backend/add.in.cpp
|
||||
backend/aliased_output.in.cpp
|
||||
backend/any.in.cpp
|
||||
backend/api.in.cpp
|
||||
backend/asin.in.cpp
|
||||
backend/asinh.in.cpp
|
||||
|
@ -1,280 +0,0 @@
|
||||
//*****************************************************************************
|
||||
// Copyright 2017-2020 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//*****************************************************************************
|
||||
|
||||
#include <algorithm>
|
||||
#include <cinttypes>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "ngraph/ngraph.hpp"
|
||||
#include "ngraph/runtime/tensor.hpp"
|
||||
#include "runtime/backend.hpp"
|
||||
#include "util/all_close.hpp"
|
||||
#include "util/all_close_f.hpp"
|
||||
#include "util/ndarray.hpp"
|
||||
#include "util/random.hpp"
|
||||
#include "util/test_control.hpp"
|
||||
#include "util/test_tools.hpp"
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
|
||||
using namespace std;
|
||||
using namespace ngraph;
|
||||
|
||||
static string s_manifest = "${MANIFEST}";
|
||||
|
||||
// Trivial case with no reduced axes.
|
||||
NGRAPH_TEST(${BACKEND_NAME}, any_trivial)
|
||||
{
|
||||
Shape shape{2, 2};
|
||||
auto A = make_shared<op::Parameter>(element::boolean, shape);
|
||||
auto f = make_shared<Function>(make_shared<op::Any>(A, AxisSet{}), ParameterVector{A});
|
||||
|
||||
auto backend = runtime::Backend::create("${BACKEND_NAME}");
|
||||
|
||||
// Create some tensors for input/output
|
||||
auto a = backend->create_tensor(element::boolean, shape);
|
||||
copy_data(a, vector<char>{0, 1, 1, 0});
|
||||
auto result = backend->create_tensor(element::boolean, shape);
|
||||
|
||||
auto handle = backend->compile(f);
|
||||
handle->call_with_validate({result}, {a});
|
||||
EXPECT_EQ((vector<char>{0, 1, 1, 0}), read_vector<char>(result));
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, any_2x2_to_scalar_true)
|
||||
{
|
||||
Shape shape{2, 2};
|
||||
auto A = make_shared<op::Parameter>(element::boolean, shape);
|
||||
auto f = make_shared<Function>(make_shared<op::Any>(A, AxisSet{0, 1}), ParameterVector{A});
|
||||
|
||||
auto backend = runtime::Backend::create("${BACKEND_NAME}");
|
||||
|
||||
// Create some tensors for input/output
|
||||
auto a = backend->create_tensor(element::boolean, shape);
|
||||
copy_data(a, vector<char>{0, 1, 1, 0});
|
||||
auto result = backend->create_tensor(element::boolean, Shape{});
|
||||
|
||||
auto handle = backend->compile(f);
|
||||
handle->call_with_validate({result}, {a});
|
||||
EXPECT_EQ((vector<char>{1}), read_vector<char>(result));
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, any_2x2_to_scalar_false)
|
||||
{
|
||||
Shape shape{2, 2};
|
||||
auto A = make_shared<op::Parameter>(element::boolean, shape);
|
||||
auto f = make_shared<Function>(make_shared<op::Any>(A, AxisSet{0, 1}), ParameterVector{A});
|
||||
|
||||
auto backend = runtime::Backend::create("${BACKEND_NAME}");
|
||||
|
||||
// Create some tensors for input/output
|
||||
auto a = backend->create_tensor(element::boolean, shape);
|
||||
copy_data(a, vector<char>{0, 0, 0, 0});
|
||||
auto result = backend->create_tensor(element::boolean, Shape{});
|
||||
|
||||
auto handle = backend->compile(f);
|
||||
handle->call_with_validate({result}, {a});
|
||||
EXPECT_EQ((vector<char>{0}), read_vector<char>(result));
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, any_2x0_to_scalar)
|
||||
{
|
||||
Shape shape{2, 0};
|
||||
auto A = make_shared<op::Parameter>(element::boolean, shape);
|
||||
auto f = make_shared<Function>(make_shared<op::Any>(A, AxisSet{0, 1}), ParameterVector{A});
|
||||
|
||||
auto backend = runtime::Backend::create("${BACKEND_NAME}");
|
||||
|
||||
// Create some tensors for input/output
|
||||
auto a = backend->create_tensor(element::boolean, shape);
|
||||
auto result = backend->create_tensor(element::boolean, Shape{});
|
||||
|
||||
auto handle = backend->compile(f);
|
||||
handle->call_with_validate({result}, {a});
|
||||
EXPECT_EQ((vector<char>{0}), read_vector<char>(result));
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, any_2x3_eliminate_col_dim)
|
||||
{
|
||||
Shape shape{2, 3};
|
||||
auto A = make_shared<op::Parameter>(element::boolean, shape);
|
||||
auto f = make_shared<Function>(make_shared<op::Any>(A, AxisSet{1}), ParameterVector{A});
|
||||
|
||||
auto backend = runtime::Backend::create("${BACKEND_NAME}");
|
||||
|
||||
// Create some tensors for input/output
|
||||
auto a = backend->create_tensor(element::boolean, shape);
|
||||
copy_data(a, test::NDArray<char, 2>({{0, 1, 0}, {0, 0, 0}}).get_vector());
|
||||
auto result = backend->create_tensor(element::boolean, Shape{2});
|
||||
|
||||
auto handle = backend->compile(f);
|
||||
handle->call_with_validate({result}, {a});
|
||||
EXPECT_EQ((vector<char>{1, 0}), read_vector<char>(result));
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, any_2x3_eliminate_row_dim)
|
||||
{
|
||||
Shape shape{2, 3};
|
||||
auto A = make_shared<op::Parameter>(element::boolean, shape);
|
||||
auto f = make_shared<Function>(make_shared<op::Any>(A, AxisSet{0}), ParameterVector{A});
|
||||
|
||||
auto backend = runtime::Backend::create("${BACKEND_NAME}");
|
||||
|
||||
// Create some tensors for input/output
|
||||
auto a = backend->create_tensor(element::boolean, shape);
|
||||
copy_data(a, test::NDArray<char, 2>({{0, 1, 0}, {0, 0, 1}}).get_vector());
|
||||
auto result = backend->create_tensor(element::boolean, Shape{3});
|
||||
|
||||
auto handle = backend->compile(f);
|
||||
handle->call_with_validate({result}, {a});
|
||||
EXPECT_EQ((vector<char>{0, 1, 1}), read_vector<char>(result));
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, any_2x2x3_eliminate_dim_0)
|
||||
{
|
||||
Shape shape{2, 2, 3};
|
||||
auto A = make_shared<op::Parameter>(element::boolean, shape);
|
||||
auto f = make_shared<Function>(make_shared<op::Any>(A, AxisSet{0}), ParameterVector{A});
|
||||
|
||||
auto backend = runtime::Backend::create("${BACKEND_NAME}");
|
||||
|
||||
// Create some tensors for input/output
|
||||
auto a = backend->create_tensor(element::boolean, shape);
|
||||
copy_data(
|
||||
a, test::NDArray<char, 3>({{{0, 1, 0}, {0, 0, 1}}, {{1, 0, 1}, {0, 0, 0}}}).get_vector());
|
||||
auto result = backend->create_tensor(element::boolean, Shape{2, 3});
|
||||
|
||||
auto handle = backend->compile(f);
|
||||
handle->call_with_validate({result}, {a});
|
||||
EXPECT_EQ((vector<char>{1, 1, 1, 0, 0, 1}), read_vector<char>(result));
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, any_2x2x3_eliminate_dim_1)
|
||||
{
|
||||
Shape shape{2, 2, 3};
|
||||
auto A = make_shared<op::Parameter>(element::boolean, shape);
|
||||
auto f = make_shared<Function>(make_shared<op::Any>(A, AxisSet{1}), ParameterVector{A});
|
||||
|
||||
auto backend = runtime::Backend::create("${BACKEND_NAME}");
|
||||
|
||||
// Create some tensors for input/output
|
||||
auto a = backend->create_tensor(element::boolean, shape);
|
||||
copy_data(
|
||||
a, test::NDArray<char, 3>({{{0, 1, 0}, {0, 0, 1}}, {{1, 0, 1}, {0, 0, 0}}}).get_vector());
|
||||
auto result = backend->create_tensor(element::boolean, Shape{2, 3});
|
||||
|
||||
auto handle = backend->compile(f);
|
||||
handle->call_with_validate({result}, {a});
|
||||
EXPECT_EQ((vector<char>{0, 1, 1, 1, 0, 1}), read_vector<char>(result));
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, any_2x2x3_eliminate_dim_2)
|
||||
{
|
||||
Shape shape{2, 2, 3};
|
||||
auto A = make_shared<op::Parameter>(element::boolean, shape);
|
||||
auto f = make_shared<Function>(make_shared<op::Any>(A, AxisSet{2}), ParameterVector{A});
|
||||
|
||||
auto backend = runtime::Backend::create("${BACKEND_NAME}");
|
||||
|
||||
// Create some tensors for input/output
|
||||
auto a = backend->create_tensor(element::boolean, shape);
|
||||
copy_data(
|
||||
a, test::NDArray<char, 3>({{{0, 1, 0}, {0, 0, 1}}, {{1, 0, 1}, {0, 0, 0}}}).get_vector());
|
||||
auto result = backend->create_tensor(element::boolean, Shape{2, 2});
|
||||
|
||||
auto handle = backend->compile(f);
|
||||
handle->call_with_validate({result}, {a});
|
||||
EXPECT_EQ((vector<char>{1, 1, 1, 0}), read_vector<char>(result));
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, any_2x2x3_eliminate_dims_0_1)
|
||||
{
|
||||
Shape shape{2, 2, 3};
|
||||
auto A = make_shared<op::Parameter>(element::boolean, shape);
|
||||
auto f = make_shared<Function>(make_shared<op::Any>(A, AxisSet{0, 1}), ParameterVector{A});
|
||||
|
||||
auto backend = runtime::Backend::create("${BACKEND_NAME}");
|
||||
|
||||
// Create some tensors for input/output
|
||||
auto a = backend->create_tensor(element::boolean, shape);
|
||||
copy_data(
|
||||
a, test::NDArray<char, 3>({{{0, 1, 0}, {0, 0, 1}}, {{1, 0, 1}, {0, 0, 0}}}).get_vector());
|
||||
auto result = backend->create_tensor(element::boolean, Shape{3});
|
||||
|
||||
auto handle = backend->compile(f);
|
||||
handle->call_with_validate({result}, {a});
|
||||
EXPECT_EQ((vector<char>{1, 1, 1}), read_vector<char>(result));
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, any_2x2x3_eliminate_dims_0_2)
|
||||
{
|
||||
Shape shape{2, 2, 3};
|
||||
auto A = make_shared<op::Parameter>(element::boolean, shape);
|
||||
auto f = make_shared<Function>(make_shared<op::Any>(A, AxisSet{0, 2}), ParameterVector{A});
|
||||
|
||||
auto backend = runtime::Backend::create("${BACKEND_NAME}");
|
||||
|
||||
// Create some tensors for input/output
|
||||
auto a = backend->create_tensor(element::boolean, shape);
|
||||
copy_data(
|
||||
a, test::NDArray<char, 3>({{{0, 1, 0}, {0, 0, 1}}, {{1, 0, 1}, {0, 0, 0}}}).get_vector());
|
||||
auto result = backend->create_tensor(element::boolean, Shape{2});
|
||||
|
||||
auto handle = backend->compile(f);
|
||||
handle->call_with_validate({result}, {a});
|
||||
EXPECT_EQ((vector<char>{1, 1}), read_vector<char>(result));
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, any_2x2x3_eliminate_dims_1_2)
|
||||
{
|
||||
Shape shape{2, 2, 3};
|
||||
auto A = make_shared<op::Parameter>(element::boolean, shape);
|
||||
auto f = make_shared<Function>(make_shared<op::Any>(A, AxisSet{1, 2}), ParameterVector{A});
|
||||
|
||||
auto backend = runtime::Backend::create("${BACKEND_NAME}");
|
||||
|
||||
// Create some tensors for input/output
|
||||
auto a = backend->create_tensor(element::boolean, shape);
|
||||
copy_data(
|
||||
a, test::NDArray<char, 3>({{{0, 1, 0}, {0, 0, 1}}, {{1, 0, 1}, {0, 0, 0}}}).get_vector());
|
||||
auto result = backend->create_tensor(element::boolean, Shape{2});
|
||||
|
||||
auto handle = backend->compile(f);
|
||||
handle->call_with_validate({result}, {a});
|
||||
EXPECT_EQ((vector<char>{1, 1}), read_vector<char>(result));
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, any_2x2x3_eliminate_dims_0_1_2)
|
||||
{
|
||||
Shape shape{2, 2, 3};
|
||||
auto A = make_shared<op::Parameter>(element::boolean, shape);
|
||||
auto f = make_shared<Function>(make_shared<op::Any>(A, AxisSet{0, 1, 2}), ParameterVector{A});
|
||||
|
||||
auto backend = runtime::Backend::create("${BACKEND_NAME}");
|
||||
|
||||
// Create some tensors for input/output
|
||||
auto a = backend->create_tensor(element::boolean, shape);
|
||||
copy_data(
|
||||
a, test::NDArray<char, 3>({{{0, 1, 0}, {0, 0, 1}}, {{1, 0, 1}, {0, 0, 0}}}).get_vector());
|
||||
auto result = backend->create_tensor(element::boolean, Shape{});
|
||||
|
||||
auto handle = backend->compile(f);
|
||||
handle->call_with_validate({result}, {a});
|
||||
EXPECT_EQ((vector<char>{1}), read_vector<char>(result));
|
||||
}
|
@ -1444,34 +1444,6 @@ TEST(constant_folding, const_reduce_logical_and__keepdims_3d)
|
||||
ASSERT_EQ(values_expected, values_out);
|
||||
}
|
||||
|
||||
TEST(constant_folding, const_any)
|
||||
{
|
||||
Shape input_shape{3, 3};
|
||||
|
||||
vector<char> values_in{1, 0, 0, 1, 0, 1, 0, 0, 0};
|
||||
auto constant = op::Constant::create(element::boolean, input_shape, values_in);
|
||||
auto convert = make_shared<op::Any>(constant, AxisSet{1});
|
||||
convert->set_friendly_name("test");
|
||||
auto f = make_shared<Function>(convert, ParameterVector{});
|
||||
|
||||
pass::Manager pass_manager;
|
||||
pass_manager.register_pass<pass::ConstantFolding>();
|
||||
pass_manager.run_passes(f);
|
||||
|
||||
ASSERT_EQ(count_ops_of_type<op::Any>(f), 0);
|
||||
ASSERT_EQ(count_ops_of_type<op::Constant>(f), 1);
|
||||
|
||||
auto new_const =
|
||||
as_type_ptr<op::Constant>(f->get_results().at(0)->input_value(0).get_node_shared_ptr());
|
||||
ASSERT_TRUE(new_const);
|
||||
ASSERT_EQ(new_const->get_friendly_name(), "test");
|
||||
auto values_out = new_const->get_vector<char>();
|
||||
|
||||
vector<char> values_expected{1, 1, 0};
|
||||
|
||||
ASSERT_EQ(values_expected, values_out);
|
||||
}
|
||||
|
||||
TEST(constant_folding, const_reduce_logical_or__no_keepdims)
|
||||
{
|
||||
const Shape input_shape{3, 3};
|
||||
|
@ -56,15 +56,6 @@ namespace
|
||||
EXPECT_FALSE(op::is_binary_elementwise_logical(&node));
|
||||
}
|
||||
|
||||
void op_is_Any()
|
||||
{
|
||||
op::Any node;
|
||||
EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node));
|
||||
EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node));
|
||||
EXPECT_FALSE(op::is_binary_elementwise_comparison(&node));
|
||||
EXPECT_FALSE(op::is_binary_elementwise_logical(&node));
|
||||
}
|
||||
|
||||
void op_is_Asin()
|
||||
{
|
||||
op::Asin node;
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "ngraph/runtime/aligned_buffer.hpp"
|
||||
#include "ngraph/runtime/reference/abs.hpp"
|
||||
#include "ngraph/runtime/reference/acos.hpp"
|
||||
#include "ngraph/runtime/reference/any.hpp"
|
||||
#include "ngraph/runtime/reference/asin.hpp"
|
||||
#include "ngraph/runtime/reference/atan.hpp"
|
||||
#include "ngraph/runtime/reference/atan2.hpp"
|
||||
@ -208,16 +207,6 @@ protected:
|
||||
args[0]->get_data_ptr<const T>(), out[0]->get_data_ptr<T>(), element_count);
|
||||
break;
|
||||
}
|
||||
case OP_TYPEID::Any:
|
||||
{
|
||||
const op::Any* any = static_cast<const op::Any*>(&node);
|
||||
reference::any(args[0]->get_data_ptr<const char>(),
|
||||
out[0]->get_data_ptr<char>(),
|
||||
node.get_input_shape(0),
|
||||
any->get_reduction_axes(),
|
||||
false);
|
||||
break;
|
||||
}
|
||||
case OP_TYPEID::Asin:
|
||||
{
|
||||
size_t element_count = shape_size(node.get_output_shape(0));
|
||||
|
@ -53,7 +53,6 @@
|
||||
NGRAPH_OP(Abs, ngraph::op)
|
||||
NGRAPH_OP(Acos, ngraph::op)
|
||||
NGRAPH_OP(Add, ngraph::op)
|
||||
NGRAPH_OP(Any, ngraph::op)
|
||||
NGRAPH_OP(Asin, ngraph::op)
|
||||
NGRAPH_OP(Atan, ngraph::op)
|
||||
NGRAPH_OP(AvgPool, ngraph::op::v0)
|
||||
|
@ -1,161 +0,0 @@
|
||||
//*****************************************************************************
|
||||
// Copyright 2017-2020 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//*****************************************************************************
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "ngraph/ngraph.hpp"
|
||||
#include "util/type_prop.hpp"
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
|
||||
using namespace std;
|
||||
using namespace ngraph;
|
||||
|
||||
TEST(type_prop, any_deduce)
|
||||
{
|
||||
auto param_0 = make_shared<op::Parameter>(element::boolean, Shape{2, 4});
|
||||
|
||||
auto r0 = make_shared<op::Any>(param_0, AxisSet{0});
|
||||
ASSERT_EQ(r0->get_element_type(), element::boolean);
|
||||
ASSERT_EQ(r0->get_shape(), (Shape{4}));
|
||||
|
||||
auto r1 = make_shared<op::Any>(param_0, AxisSet{1});
|
||||
ASSERT_EQ(r1->get_element_type(), element::boolean);
|
||||
ASSERT_EQ(r1->get_shape(), (Shape{2}));
|
||||
|
||||
auto r01 = make_shared<op::Any>(param_0, AxisSet{0, 1});
|
||||
ASSERT_EQ(r01->get_element_type(), element::boolean);
|
||||
ASSERT_EQ(r01->get_shape(), (Shape{}));
|
||||
|
||||
auto r_none = make_shared<op::Any>(param_0, AxisSet{});
|
||||
ASSERT_EQ(r_none->get_element_type(), element::boolean);
|
||||
ASSERT_EQ(r_none->get_shape(), (Shape{2, 4}));
|
||||
}
|
||||
|
||||
TEST(type_prop, any_deduce_et_dynamic)
|
||||
{
|
||||
auto param_0 = make_shared<op::Parameter>(element::dynamic, Shape{2, 4});
|
||||
|
||||
auto r0 = make_shared<op::Any>(param_0, AxisSet{0});
|
||||
ASSERT_EQ(r0->get_element_type(), element::boolean);
|
||||
ASSERT_EQ(r0->get_shape(), (Shape{4}));
|
||||
|
||||
auto r1 = make_shared<op::Any>(param_0, AxisSet{1});
|
||||
ASSERT_EQ(r1->get_element_type(), element::boolean);
|
||||
ASSERT_EQ(r1->get_shape(), (Shape{2}));
|
||||
|
||||
auto r01 = make_shared<op::Any>(param_0, AxisSet{0, 1});
|
||||
ASSERT_EQ(r01->get_element_type(), element::boolean);
|
||||
ASSERT_EQ(r01->get_shape(), (Shape{}));
|
||||
|
||||
auto r_none = make_shared<op::Any>(param_0, AxisSet{});
|
||||
ASSERT_EQ(r_none->get_element_type(), element::boolean);
|
||||
ASSERT_EQ(r_none->get_shape(), (Shape{2, 4}));
|
||||
}
|
||||
|
||||
TEST(type_prop, any_et_non_boolean)
|
||||
{
|
||||
auto param_0 = make_shared<op::Parameter>(element::i32, Shape{2, 4});
|
||||
|
||||
try
|
||||
{
|
||||
auto r = make_shared<op::Any>(param_0, AxisSet{0, 1});
|
||||
// Should have thrown, so fail if it didn't
|
||||
FAIL() << "Did not detect invalid element type for Any";
|
||||
}
|
||||
catch (const NodeValidationFailure& error)
|
||||
{
|
||||
EXPECT_HAS_SUBSTRING(error.what(), std::string("Input element type must be boolean"));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
FAIL() << "Deduced type check failed for unexpected reason";
|
||||
}
|
||||
}
|
||||
|
||||
TEST(type_prop, any_axis_oob)
|
||||
{
|
||||
auto param_0 = make_shared<op::Parameter>(element::boolean, Shape{2, 4});
|
||||
|
||||
try
|
||||
{
|
||||
auto r = make_shared<op::Any>(param_0, AxisSet{0, 2, 1});
|
||||
// Should have thrown, so fail if it didn't
|
||||
FAIL() << "Did not detect out-of-bound axis for Any";
|
||||
}
|
||||
catch (const NodeValidationFailure& error)
|
||||
{
|
||||
EXPECT_HAS_SUBSTRING(error.what(), std::string("Reduction axis (2) is out of bounds"));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
FAIL() << "Deduced type check failed for unexpected reason";
|
||||
}
|
||||
}
|
||||
|
||||
TEST(type_prop, any_partial_rank_dynamic)
|
||||
{
|
||||
auto param = make_shared<op::Parameter>(element::boolean, PartialShape::dynamic());
|
||||
auto axes = AxisSet{2385, 0, 4404}; // arbitrary
|
||||
auto any = make_shared<op::Any>(param, axes);
|
||||
|
||||
EXPECT_EQ(any->get_output_element_type(0), element::boolean);
|
||||
EXPECT_TRUE(any->get_output_partial_shape(0).is_dynamic());
|
||||
}
|
||||
|
||||
TEST(type_prop, any_partial_rank_static_dynamic_ok_result_static)
|
||||
{
|
||||
auto param = make_shared<op::Parameter>(element::boolean,
|
||||
PartialShape{1, 2, Dimension::dynamic(), 4, 5});
|
||||
auto axes = AxisSet{2, 3};
|
||||
auto any = make_shared<op::Any>(param, axes);
|
||||
|
||||
EXPECT_EQ(any->get_output_element_type(0), element::boolean);
|
||||
EXPECT_EQ(any->get_shape(), (Shape{1, 2, 5}));
|
||||
}
|
||||
|
||||
TEST(type_prop, any_partial_rank_static_dynamic_ok_result_dynamic)
|
||||
{
|
||||
auto param = make_shared<op::Parameter>(
|
||||
element::boolean, PartialShape{1, 2, Dimension::dynamic(), 4, Dimension::dynamic()});
|
||||
auto axes = AxisSet{2, 3};
|
||||
auto any = make_shared<op::Any>(param, axes);
|
||||
|
||||
EXPECT_EQ(any->get_output_element_type(0), element::boolean);
|
||||
EXPECT_TRUE(
|
||||
any->get_output_partial_shape(0).same_scheme(PartialShape{1, 2, Dimension::dynamic()}));
|
||||
}
|
||||
|
||||
TEST(type_prop, any_partial_rank_static_dynamic_axes_oob)
|
||||
{
|
||||
auto param = make_shared<op::Parameter>(
|
||||
element::boolean, PartialShape{1, 2, Dimension::dynamic(), 4, Dimension::dynamic()});
|
||||
auto axes = AxisSet{2, 5, 1};
|
||||
|
||||
try
|
||||
{
|
||||
auto any = make_shared<op::Any>(param, axes);
|
||||
// Should have thrown, so fail if it didn't
|
||||
FAIL() << "Did not detect out-of-bound axis for Any (rank-static dynamic input)";
|
||||
}
|
||||
catch (const NodeValidationFailure& error)
|
||||
{
|
||||
EXPECT_HAS_SUBSTRING(error.what(), std::string("Reduction axis (5) is out of bounds"));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
FAIL() << "Deduced type check failed for unexpected reason";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user