/* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ #include // Declares the operator #include #include #include #include #include #include using namespace ::testing; using exec_aten::ScalarType; using exec_aten::Tensor; using torch::executor::testing::TensorFactory; class OpCeilTest : public OperatorTest { protected: Tensor& op_ceil_out(const Tensor& self, Tensor& out) { return torch::executor::aten::ceil_outf(context_, self, out); } }; TEST_F(OpCeilTest, SanityCheck) { TensorFactory tf; Tensor in = tf.make({1, 7}, {-3.0, -2.99, -1.01, 0.0, 1.01, 2.99, 3.0}); Tensor out = tf.zeros({1, 7}); Tensor expected = tf.make({1, 7}, {-3.0, -2.0, -1.0, 0.0, 2.0, 3.0, 3.0}); Tensor ret = op_ceil_out(in, out); EXPECT_TENSOR_EQ(out, ret); EXPECT_TENSOR_EQ(out, expected); } TEST_F(OpCeilTest, HalfSupport) { if (torch::executor::testing::SupportedFeatures::get()->is_aten) { GTEST_SKIP() << "Test Half support only for ExecuTorch mode"; } TensorFactory tf; Tensor in = tf.make({1, 7}, {-3.0, -2.99, -1.01, 0.0, 1.01, 2.99, 3.0}); Tensor out = tf.zeros({1, 7}); Tensor expected = tf.make({1, 7}, {-3.0, -2.0, -1.0, 0.0, 2.0, 3.0, 3.0}); Tensor ret = op_ceil_out(in, out); EXPECT_TENSOR_EQ(out, ret); EXPECT_TENSOR_EQ(out, expected); }