Skip to content

Commit 6961eed

Browse files
authored
[ET-VK] Add test to track sizes of various objects
Differential Revision: D62144400 Pull Request resolved: #5039
1 parent bc56a97 commit 6961eed

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

backends/vulkan/test/vulkan_compute_api_test.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,28 @@ TEST_F(VulkanComputeAPITest, texture_virtual_resize) {
992992
graph.get_tensor(name.value)->staging_buffer_numel()); \
993993
graph.copy_from_staging(name.staging, data_##name.data(), data_##name.size());
994994

995+
// The purpose of this test is simply to track the size of various classes over
996+
// time, in the interest of making sure that they doesn't grow too large.
997+
TEST_F(VulkanComputeAPITest, print_object_sizes) {
998+
#define PRINT_SIZE(name) \
999+
std::cout << #name << " size: " << sizeof(name) << " B" << std::endl
1000+
PRINT_SIZE(vTensor);
1001+
PRINT_SIZE(Value);
1002+
PRINT_SIZE(StagingBuffer);
1003+
PRINT_SIZE(ComputeGraph);
1004+
PRINT_SIZE(ExecuteNode);
1005+
#undef PRINT_SIZE
1006+
1007+
// The actual sizes of each object is dependent on the platform. However, we
1008+
// can alert ourselves to any significant changes in the sizes of these
1009+
// objects by checking the `sizeof()` the class against some loose thresholds.
1010+
EXPECT_TRUE(sizeof(vTensor) < 1800);
1011+
EXPECT_TRUE(sizeof(Value) < 2400);
1012+
EXPECT_TRUE(sizeof(StagingBuffer) < 500);
1013+
EXPECT_TRUE(sizeof(ComputeGraph) < 500);
1014+
EXPECT_TRUE(sizeof(ExecuteNode) < 500);
1015+
}
1016+
9951017
TEST(VulkanComputeGraphTest, test_values_scalars) {
9961018
GraphConfig config;
9971019
ComputeGraph graph(config);

0 commit comments

Comments
 (0)