// Copyright © Advanced Micro Devices, Inc., or its affiliates. // SPDX-License-Identifier: MIT #include #include #include #include #include #include using namespace hipdnn_flatbuffers_sdk::flatbuffer_utilities; using namespace hipdnn_flatbuffers_sdk::data_objects; TEST(TestNodeWrapper, NullBufferIsInvalid) { EXPECT_THROW(const NodeWrapper wrapper(nullptr), std::invalid_argument); } TEST(TestNodeWrapper, EnsureTheNodeIsWrappedCorrectly) { flatbuffers::FlatBufferBuilder builder = hipdnn_test_sdk::utilities::createValidBatchnormInferenceGraph(); auto serializedGraph = builder.Release(); auto shallowGraph = flatbuffers::GetRoot(serializedGraph.data()); const NodeWrapper wrapper(shallowGraph->nodes()->Get(0)); EXPECT_TRUE(wrapper.isValid()); EXPECT_EQ(wrapper.attributesType(), hipdnn_flatbuffers_sdk::data_objects::NodeAttributes::BatchnormInferenceAttributes); EXPECT_NO_THROW( wrapper.attributesAs()); EXPECT_THROW( wrapper.attributesAs(), std::invalid_argument); }