1 /*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the root directory of this source tree.
7 */
8
9 #include <executorch/kernels/test/FunctionHeaderWrapper.h> // Declares the operator
10 #include <executorch/kernels/test/TestUtil.h>
11 #include <executorch/kernels/test/supported_features.h>
12 #include <executorch/runtime/core/exec_aten/exec_aten.h>
13 #include <executorch/runtime/core/exec_aten/testing_util/tensor_factory.h>
14 #include <executorch/runtime/core/exec_aten/testing_util/tensor_util.h>
15
16 #include <gtest/gtest.h>
17
18 using namespace ::testing;
19 using exec_aten::Scalar;
20 using exec_aten::ScalarType;
21 using exec_aten::Tensor;
22 using torch::executor::testing::SupportedFeatures;
23 using torch::executor::testing::TensorFactory;
24
op_trunc_out(const Tensor & a,Tensor & out)25 Tensor& op_trunc_out(const Tensor& a, Tensor& out) {
26 executorch::runtime::KernelRuntimeContext context{};
27 return torch::executor::aten::trunc_outf(context, a, out);
28 }
29
TEST(OpTruncOutTest,SmokeTest)30 TEST(OpTruncOutTest, SmokeTest) {
31 TensorFactory<ScalarType::Double> tfDouble;
32
33 Tensor self =
34 tfDouble.make({1, 6}, {60.5, 16.25, -95.0, -36.125, 19.0, -47.75});
35 Tensor out = tfDouble.zeros({1, 6});
36 Tensor out_expected =
37 tfDouble.make({1, 6}, {60.0, 16.0, -95.0, -36.0, 19.0, -47.0});
38 op_trunc_out(self, out);
39 EXPECT_TENSOR_CLOSE(out, out_expected);
40 }
41