Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion runtime/core/portable_type/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../..)

include(${EXECUTORCH_ROOT}/build/Test.cmake)

set(_test_srcs optional_test.cpp executor_tensor_test.cpp half_test.cpp
set(_test_srcs optional_test.cpp tensor_test.cpp half_test.cpp
scalar_test.cpp tensor_impl_test.cpp
)

Expand Down
4 changes: 2 additions & 2 deletions runtime/core/portable_type/test/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def define_common_targets():
)

runtime.cxx_test(
name = "executor_tensor_test",
srcs = ["executor_tensor_test.cpp"],
name = "tensor_test",
srcs = ["tensor_test.cpp"],
deps = [
"//executorch/runtime/core/portable_type:portable_type",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,25 @@
*/

#include <executorch/runtime/core/portable_type/tensor.h>
#include <executorch/test/utils/DeathTest.h>

#include <gtest/gtest.h>

#include <executorch/runtime/platform/runtime.h>
#include <executorch/test/utils/DeathTest.h>

namespace torch {
namespace executor {

TEST(TensorTest, InvalidScalarType) {
class TensorTest : public ::testing::Test {
protected:
void SetUp() override {
// Since these tests cause ET_LOG to be called, the PAL must be initialized
// first.
runtime_init();
}
};

TEST_F(TensorTest, InvalidScalarType) {
TensorImpl::SizesType sizes[1] = {1};

// Undefined, which is sort of a special case since it's not part of the
Expand All @@ -28,7 +40,7 @@ TEST(TensorTest, InvalidScalarType) {
ET_EXPECT_DEATH({ TensorImpl y(static_cast<ScalarType>(-1), 1, sizes); }, "");
}

TEST(TensorTest, SetData) {
TEST_F(TensorTest, SetData) {
TensorImpl::SizesType sizes[1] = {5};
TensorImpl::DimOrderType dim_order[1] = {0};
int32_t data[5] = {0, 0, 1, 0, 0};
Expand All @@ -39,7 +51,7 @@ TEST(TensorTest, SetData) {
EXPECT_EQ(a.const_data_ptr(), nullptr);
}

TEST(TensorTest, Strides) {
TEST_F(TensorTest, Strides) {
TensorImpl::SizesType sizes[2] = {2, 2};
TensorImpl::DimOrderType dim_order[2] = {0, 1};
int32_t data[4] = {0, 0, 1, 1};
Expand All @@ -53,7 +65,7 @@ TEST(TensorTest, Strides) {
EXPECT_EQ(a.const_data_ptr<int32_t>()[0 + a.strides()[0]], 1);
}

TEST(TensorTest, ModifyDataOfConstTensor) {
TEST_F(TensorTest, ModifyDataOfConstTensor) {
TensorImpl::SizesType sizes[1] = {1};
TensorImpl::DimOrderType dim_order[2] = {0};
int32_t data[1] = {1};
Expand Down
2 changes: 1 addition & 1 deletion test/utils/OSSTestConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"directory": "runtime/core/portable_type/test",
"sources": [
"optional_test.cpp",
"executor_tensor_test.cpp",
"tensor_test.cpp",
"half_test.cpp",
"scalar_test.cpp",
"tensor_impl_test.cpp"
Expand Down
Loading