Skip to content

Commit 2a4e522

Browse files
SamuelReederclaude
andauthored
[hipdnn] Update backend to use hipdnn_flatbuffers_sdk for FlatBuffers types (ROCm#6255)
## Summary - Added `hipdnn_flatbuffers_sdk` to `hipdnn_backend_private` CMake link libraries - Replaced all `hipdnn_data_sdk/data_objects/`, `hipdnn_data_sdk/flatbuffer_utilities/`, and `hipdnn_data_sdk/utilities/json/` include paths with `hipdnn_flatbuffers_sdk/` equivalents across 97 backend source and test files - FlatBuffers remains an internal implementation detail of the backend — no symbols exported ## Test plan - [x] hipDNN build passes - [x] All 9 backend tests pass (6 unit, 3 integration) - [x] No stale `hipdnn_data_sdk` FlatBuffers include paths remain in backend 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent ae361fa commit 2a4e522

128 files changed

Lines changed: 965 additions & 927 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

projects/hipdnn/backend/src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ target_include_directories(
6969
)
7070

7171
target_compile_options(hipdnn_backend_private PRIVATE ${HIPDNN_WARNING_COMPILE_OPTIONS} ${HIPDNN_NO_RTTI_OPTIONS})
72-
target_link_libraries(hipdnn_backend_private PUBLIC hip::host hipdnn_data_sdk hipdnn_plugin_sdk)
72+
target_link_libraries(hipdnn_backend_private PUBLIC hip::host hipdnn_data_sdk hipdnn_plugin_sdk hipdnn_flatbuffers_sdk)
7373
target_link_libraries(hipdnn_backend_private PRIVATE ${CMAKE_DL_LIBS})
7474
target_compile_definitions(hipdnn_backend_private PRIVATE HIPDNN_BACKEND_COMPILATION)
7575

projects/hipdnn/backend/src/FlatbufferUtilities.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@ namespace hipdnn_backend
1111
namespace flatbuffer_utilities
1212
{
1313

14-
void convertSerializedGraphToGraph(const uint8_t* buffer,
15-
size_t size,
16-
std::unique_ptr<hipdnn_data_sdk::data_objects::GraphT>& graphOut)
14+
void convertSerializedGraphToGraph(
15+
const uint8_t* buffer,
16+
size_t size,
17+
std::unique_ptr<hipdnn_flatbuffers_sdk::data_objects::GraphT>& graphOut)
1718
{
1819
flatbuffers::Verifier verifier(buffer, size);
19-
if(!verifier.VerifyBuffer<hipdnn_data_sdk::data_objects::Graph>())
20+
if(!verifier.VerifyBuffer<hipdnn_flatbuffers_sdk::data_objects::Graph>())
2021
{
2122
throw HipdnnException(HIPDNN_STATUS_BAD_PARAM,
2223
"Invalid buffer: unable to verify the flatbuffer schema.");
2324
}
2425

25-
auto graph = hipdnn_data_sdk::data_objects::UnPackGraph(buffer);
26+
auto graph = hipdnn_flatbuffers_sdk::data_objects::UnPackGraph(buffer);
2627
if(graph == nullptr)
2728
{
2829
throw HipdnnException(HIPDNN_STATUS_INTERNAL_ERROR,

projects/hipdnn/backend/src/FlatbufferUtilities.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
#pragma once
55

66
#include "HipdnnStatus.h"
7-
#include <hipdnn_data_sdk/data_objects/graph_generated.h>
7+
#include <hipdnn_flatbuffers_sdk/data_objects/graph_generated.h>
88
#include <memory>
99

1010
namespace hipdnn_backend::flatbuffer_utilities
1111
{
1212
void convertSerializedGraphToGraph(
1313
const uint8_t* buffer,
1414
size_t size,
15-
std::unique_ptr<hipdnn_data_sdk::data_objects::GraphT>& graphOut);
15+
std::unique_ptr<hipdnn_flatbuffers_sdk::data_objects::GraphT>& graphOut);
1616
} // namespace hipdnn_backend::flatbuffer_utilities

projects/hipdnn/backend/src/descriptors/BatchnormBackwardOperationDescriptor.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void BatchnormBackwardOperationDescriptor::finalize()
3131
THROW_IF_NULL(_dbiasDesc,
3232
HIPDNN_STATUS_BAD_PARAM,
3333
"BatchnormBackwardOperationDescriptor::finalize() failed: DBIAS tensor not set");
34-
THROW_IF_TRUE(_computeDataType == hipdnn_data_sdk::data_objects::DataType::UNSET,
34+
THROW_IF_TRUE(_computeDataType == hipdnn_flatbuffers_sdk::data_objects::DataType::UNSET,
3535
HIPDNN_STATUS_BAD_PARAM,
3636
"BatchnormBackwardOperationDescriptor::finalize() failed: compute data type not "
3737
"set");
@@ -305,13 +305,13 @@ std::vector<std::shared_ptr<TensorDescriptor>>
305305
return result;
306306
}
307307

308-
std::unique_ptr<hipdnn_data_sdk::data_objects::NodeT>
308+
std::unique_ptr<hipdnn_flatbuffers_sdk::data_objects::NodeT>
309309
BatchnormBackwardOperationDescriptor::buildNode() const
310310
{
311-
auto node = std::make_unique<hipdnn_data_sdk::data_objects::NodeT>();
311+
auto node = std::make_unique<hipdnn_flatbuffers_sdk::data_objects::NodeT>();
312312
node->name = _name;
313313
node->compute_data_type = _computeDataType;
314-
node->attributes.Set(hipdnn_data_sdk::data_objects::BatchnormBackwardAttributesT(_data));
314+
node->attributes.Set(hipdnn_flatbuffers_sdk::data_objects::BatchnormBackwardAttributesT(_data));
315315
return node;
316316
}
317317

@@ -340,14 +340,14 @@ std::string BatchnormBackwardOperationDescriptor::toString() const
340340
: "nullopt";
341341
str += ", peer_stats_uids=" + vecToString(_data.peer_stats_tensor_uid);
342342
str += ", compute_data_type=";
343-
str += hipdnn_data_sdk::data_objects::EnumNameDataType(_computeDataType);
343+
str += hipdnn_flatbuffers_sdk::data_objects::EnumNameDataType(_computeDataType);
344344
str += "}";
345345
return str;
346346
}
347347

348348
std::shared_ptr<BatchnormBackwardOperationDescriptor>
349349
BatchnormBackwardOperationDescriptor::fromNode(
350-
const hipdnn_data_sdk::data_objects::NodeT& nodeT,
350+
const hipdnn_flatbuffers_sdk::data_objects::NodeT& nodeT,
351351
const std::unordered_map<int64_t, std::shared_ptr<TensorDescriptor>>& tensorMap)
352352
{
353353
const auto* attrs = nodeT.attributes.AsBatchnormBackwardAttributes();

projects/hipdnn/backend/src/descriptors/BatchnormBackwardOperationDescriptor.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "BackendDescriptor.hpp"
77
#include "IGraphOperation.hpp"
88
#include "TensorDescriptor.hpp"
9-
#include <hipdnn_data_sdk/data_objects/batchnorm_backward_attributes_generated.h>
9+
#include <hipdnn_flatbuffers_sdk/data_objects/batchnorm_backward_attributes_generated.h>
1010
#include <unordered_map>
1111

1212
namespace hipdnn_backend
@@ -31,7 +31,7 @@ class BatchnormBackwardOperationDescriptor
3131
const void* arrayOfElements) override;
3232

3333
// Direct access to the underlying T struct for OperationGraphBuilder
34-
const hipdnn_data_sdk::data_objects::BatchnormBackwardAttributesT& getData() const
34+
const hipdnn_flatbuffers_sdk::data_objects::BatchnormBackwardAttributesT& getData() const
3535
{
3636
return _data;
3737
}
@@ -71,28 +71,28 @@ class BatchnormBackwardOperationDescriptor
7171
}
7272

7373
// Get compute data type for the operation (used when building graph nodes)
74-
hipdnn_data_sdk::data_objects::DataType getComputeDataType() const
74+
hipdnn_flatbuffers_sdk::data_objects::DataType getComputeDataType() const
7575
{
7676
return _computeDataType;
7777
}
7878

7979
// IGraphOperation interface
8080
std::vector<std::shared_ptr<TensorDescriptor>> getTensorDescriptors() const override;
81-
std::unique_ptr<hipdnn_data_sdk::data_objects::NodeT> buildNode() const override;
81+
std::unique_ptr<hipdnn_flatbuffers_sdk::data_objects::NodeT> buildNode() const override;
8282

8383
// Creates a finalized BatchnormBackwardOperationDescriptor directly from a FlatBuffer NodeT.
8484
// Casts nodeT.attributes to BatchnormBackwardAttributesT internally, then directly assigns
8585
// the data struct, looks up tensor descriptors from the tensor map, and calls finalize().
8686
static std::shared_ptr<BatchnormBackwardOperationDescriptor>
87-
fromNode(const hipdnn_data_sdk::data_objects::NodeT& nodeT,
87+
fromNode(const hipdnn_flatbuffers_sdk::data_objects::NodeT& nodeT,
8888
const std::unordered_map<int64_t, std::shared_ptr<TensorDescriptor>>& tensorMap);
8989

9090
static hipdnnBackendDescriptorType_t getStaticType();
9191

9292
std::string toString() const override;
9393

9494
private:
95-
hipdnn_data_sdk::data_objects::BatchnormBackwardAttributesT _data;
95+
hipdnn_flatbuffers_sdk::data_objects::BatchnormBackwardAttributesT _data;
9696

9797
// Store tensor descriptor references for validation and graph building
9898
std::shared_ptr<TensorDescriptor> _dyDesc;
@@ -108,8 +108,8 @@ class BatchnormBackwardOperationDescriptor
108108
std::vector<std::shared_ptr<TensorDescriptor>> _peerStatsDescs;
109109

110110
// Compute data type for this operation (stored at node level in graph)
111-
hipdnn_data_sdk::data_objects::DataType _computeDataType
112-
= hipdnn_data_sdk::data_objects::DataType::UNSET;
111+
hipdnn_flatbuffers_sdk::data_objects::DataType _computeDataType
112+
= hipdnn_flatbuffers_sdk::data_objects::DataType::UNSET;
113113

114114
std::string _name;
115115
};

projects/hipdnn/backend/src/descriptors/BatchnormInferenceOperationDescriptor.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void BatchnormInferenceOperationDescriptor::finalize()
3232
THROW_IF_NULL(_yDesc,
3333
HIPDNN_STATUS_BAD_PARAM,
3434
"BatchnormInferenceOperationDescriptor::finalize() failed: Y tensor not set");
35-
THROW_IF_TRUE(_computeDataType == hipdnn_data_sdk::data_objects::DataType::UNSET,
35+
THROW_IF_TRUE(_computeDataType == hipdnn_flatbuffers_sdk::data_objects::DataType::UNSET,
3636
HIPDNN_STATUS_BAD_PARAM,
3737
"BatchnormInferenceOperationDescriptor::finalize() failed: compute data type not "
3838
"set");
@@ -232,13 +232,14 @@ std::vector<std::shared_ptr<TensorDescriptor>>
232232
return {_xDesc, _meanDesc, _invVarianceDesc, _scaleDesc, _biasDesc, _yDesc};
233233
}
234234

235-
std::unique_ptr<hipdnn_data_sdk::data_objects::NodeT>
235+
std::unique_ptr<hipdnn_flatbuffers_sdk::data_objects::NodeT>
236236
BatchnormInferenceOperationDescriptor::buildNode() const
237237
{
238-
auto node = std::make_unique<hipdnn_data_sdk::data_objects::NodeT>();
238+
auto node = std::make_unique<hipdnn_flatbuffers_sdk::data_objects::NodeT>();
239239
node->name = _name;
240240
node->compute_data_type = _computeDataType;
241-
node->attributes.Set(hipdnn_data_sdk::data_objects::BatchnormInferenceAttributesT(_data));
241+
node->attributes.Set(
242+
hipdnn_flatbuffers_sdk::data_objects::BatchnormInferenceAttributesT(_data));
242243
return node;
243244
}
244245

@@ -258,14 +259,14 @@ std::string BatchnormInferenceOperationDescriptor::toString() const
258259
str += ", bias_uid=" + std::to_string(_data.bias_tensor_uid);
259260
str += ", y_uid=" + std::to_string(_data.y_tensor_uid);
260261
str += ", compute_data_type=";
261-
str += hipdnn_data_sdk::data_objects::EnumNameDataType(_computeDataType);
262+
str += hipdnn_flatbuffers_sdk::data_objects::EnumNameDataType(_computeDataType);
262263
str += "}";
263264
return str;
264265
}
265266

266267
std::shared_ptr<BatchnormInferenceOperationDescriptor>
267268
BatchnormInferenceOperationDescriptor::fromNode(
268-
const hipdnn_data_sdk::data_objects::NodeT& nodeT,
269+
const hipdnn_flatbuffers_sdk::data_objects::NodeT& nodeT,
269270
const std::unordered_map<int64_t, std::shared_ptr<TensorDescriptor>>& tensorMap)
270271
{
271272
const auto* attrs = nodeT.attributes.AsBatchnormInferenceAttributes();

projects/hipdnn/backend/src/descriptors/BatchnormInferenceOperationDescriptor.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "BackendDescriptor.hpp"
77
#include "IGraphOperation.hpp"
88
#include "TensorDescriptor.hpp"
9-
#include <hipdnn_data_sdk/data_objects/batchnorm_inference_attributes_generated.h>
9+
#include <hipdnn_flatbuffers_sdk/data_objects/batchnorm_inference_attributes_generated.h>
1010
#include <unordered_map>
1111

1212
namespace hipdnn_backend
@@ -31,7 +31,7 @@ class BatchnormInferenceOperationDescriptor
3131
const void* arrayOfElements) override;
3232

3333
// Direct access to the underlying T struct for OperationGraphBuilder
34-
const hipdnn_data_sdk::data_objects::BatchnormInferenceAttributesT& getData() const
34+
const hipdnn_flatbuffers_sdk::data_objects::BatchnormInferenceAttributesT& getData() const
3535
{
3636
return _data;
3737
}
@@ -63,28 +63,28 @@ class BatchnormInferenceOperationDescriptor
6363
}
6464

6565
// Get compute data type for the operation (used when building graph nodes)
66-
hipdnn_data_sdk::data_objects::DataType getComputeDataType() const
66+
hipdnn_flatbuffers_sdk::data_objects::DataType getComputeDataType() const
6767
{
6868
return _computeDataType;
6969
}
7070

7171
// IGraphOperation interface
7272
std::vector<std::shared_ptr<TensorDescriptor>> getTensorDescriptors() const override;
73-
std::unique_ptr<hipdnn_data_sdk::data_objects::NodeT> buildNode() const override;
73+
std::unique_ptr<hipdnn_flatbuffers_sdk::data_objects::NodeT> buildNode() const override;
7474

7575
// Creates a finalized BatchnormInferenceOperationDescriptor directly from a FlatBuffer NodeT.
7676
// Casts nodeT.attributes to BatchnormInferenceAttributesT internally, then directly assigns
7777
// the data struct, looks up tensor descriptors from the tensor map, and calls finalize().
7878
static std::shared_ptr<BatchnormInferenceOperationDescriptor>
79-
fromNode(const hipdnn_data_sdk::data_objects::NodeT& nodeT,
79+
fromNode(const hipdnn_flatbuffers_sdk::data_objects::NodeT& nodeT,
8080
const std::unordered_map<int64_t, std::shared_ptr<TensorDescriptor>>& tensorMap);
8181

8282
static hipdnnBackendDescriptorType_t getStaticType();
8383

8484
std::string toString() const override;
8585

8686
private:
87-
hipdnn_data_sdk::data_objects::BatchnormInferenceAttributesT _data;
87+
hipdnn_flatbuffers_sdk::data_objects::BatchnormInferenceAttributesT _data;
8888

8989
// Store tensor descriptor references for validation and graph building
9090
std::shared_ptr<TensorDescriptor> _xDesc;
@@ -95,8 +95,8 @@ class BatchnormInferenceOperationDescriptor
9595
std::shared_ptr<TensorDescriptor> _yDesc;
9696

9797
// Compute data type for this operation (stored at node level in graph)
98-
hipdnn_data_sdk::data_objects::DataType _computeDataType
99-
= hipdnn_data_sdk::data_objects::DataType::UNSET;
98+
hipdnn_flatbuffers_sdk::data_objects::DataType _computeDataType
99+
= hipdnn_flatbuffers_sdk::data_objects::DataType::UNSET;
100100

101101
std::string _name;
102102
};

projects/hipdnn/backend/src/descriptors/BatchnormInferenceVarianceExtOperationDescriptor.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void BatchnormInferenceVarianceExtOperationDescriptor::finalize()
4141
HIPDNN_STATUS_BAD_PARAM,
4242
"BatchnormInferenceVarianceExtOperationDescriptor::finalize() failed: EPSILON "
4343
"tensor not set");
44-
THROW_IF_TRUE(_computeDataType == hipdnn_data_sdk::data_objects::DataType::UNSET,
44+
THROW_IF_TRUE(_computeDataType == hipdnn_flatbuffers_sdk::data_objects::DataType::UNSET,
4545
HIPDNN_STATUS_BAD_PARAM,
4646
"BatchnormInferenceVarianceExtOperationDescriptor::finalize() failed: compute "
4747
"data type not "
@@ -261,14 +261,14 @@ std::vector<std::shared_ptr<TensorDescriptor>>
261261
return {_xDesc, _meanDesc, _varianceDesc, _scaleDesc, _biasDesc, _yDesc, _epsilonDesc};
262262
}
263263

264-
std::unique_ptr<hipdnn_data_sdk::data_objects::NodeT>
264+
std::unique_ptr<hipdnn_flatbuffers_sdk::data_objects::NodeT>
265265
BatchnormInferenceVarianceExtOperationDescriptor::buildNode() const
266266
{
267-
auto node = std::make_unique<hipdnn_data_sdk::data_objects::NodeT>();
267+
auto node = std::make_unique<hipdnn_flatbuffers_sdk::data_objects::NodeT>();
268268
node->name = _name;
269269
node->compute_data_type = _computeDataType;
270270
node->attributes.Set(
271-
hipdnn_data_sdk::data_objects::BatchnormInferenceAttributesVarianceExtT(_data));
271+
hipdnn_flatbuffers_sdk::data_objects::BatchnormInferenceAttributesVarianceExtT(_data));
272272
return node;
273273
}
274274

@@ -289,14 +289,14 @@ std::string BatchnormInferenceVarianceExtOperationDescriptor::toString() const
289289
str += ", y_uid=" + std::to_string(_data.y_tensor_uid);
290290
str += ", epsilon_uid=" + std::to_string(_data.epsilon_tensor_uid);
291291
str += ", compute_data_type=";
292-
str += hipdnn_data_sdk::data_objects::EnumNameDataType(_computeDataType);
292+
str += hipdnn_flatbuffers_sdk::data_objects::EnumNameDataType(_computeDataType);
293293
str += "}";
294294
return str;
295295
}
296296

297297
std::shared_ptr<BatchnormInferenceVarianceExtOperationDescriptor>
298298
BatchnormInferenceVarianceExtOperationDescriptor::fromNode(
299-
const hipdnn_data_sdk::data_objects::NodeT& nodeT,
299+
const hipdnn_flatbuffers_sdk::data_objects::NodeT& nodeT,
300300
const std::unordered_map<int64_t, std::shared_ptr<TensorDescriptor>>& tensorMap)
301301
{
302302
const auto* attrs = nodeT.attributes.AsBatchnormInferenceAttributesVarianceExt();

projects/hipdnn/backend/src/descriptors/BatchnormInferenceVarianceExtOperationDescriptor.hpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#include "BackendDescriptor.hpp"
77
#include "IGraphOperation.hpp"
88
#include "TensorDescriptor.hpp"
9-
#include <hipdnn_data_sdk/data_objects/batchnorm_inference_attributes_variance_ext_generated.h>
10-
#include <hipdnn_data_sdk/data_objects/graph_generated.h>
9+
#include <hipdnn_flatbuffers_sdk/data_objects/batchnorm_inference_attributes_variance_ext_generated.h>
10+
#include <hipdnn_flatbuffers_sdk/data_objects/graph_generated.h>
1111
#include <unordered_map>
1212

1313
namespace hipdnn_backend
@@ -32,7 +32,8 @@ class BatchnormInferenceVarianceExtOperationDescriptor
3232
const void* arrayOfElements) override;
3333

3434
// Direct access to the underlying T struct for OperationGraphBuilder
35-
const hipdnn_data_sdk::data_objects::BatchnormInferenceAttributesVarianceExtT& getData() const
35+
const hipdnn_flatbuffers_sdk::data_objects::BatchnormInferenceAttributesVarianceExtT&
36+
getData() const
3637
{
3738
return _data;
3839
}
@@ -68,26 +69,26 @@ class BatchnormInferenceVarianceExtOperationDescriptor
6869
}
6970

7071
// Get compute data type for the operation (used when building graph nodes)
71-
hipdnn_data_sdk::data_objects::DataType getComputeDataType() const
72+
hipdnn_flatbuffers_sdk::data_objects::DataType getComputeDataType() const
7273
{
7374
return _computeDataType;
7475
}
7576

7677
// IGraphOperation interface
7778
std::vector<std::shared_ptr<TensorDescriptor>> getTensorDescriptors() const override;
78-
std::unique_ptr<hipdnn_data_sdk::data_objects::NodeT> buildNode() const override;
79+
std::unique_ptr<hipdnn_flatbuffers_sdk::data_objects::NodeT> buildNode() const override;
7980

8081
/// Reconstructs a descriptor from a FlatBuffer NodeT and a pre-built tensor map.
8182
static std::shared_ptr<BatchnormInferenceVarianceExtOperationDescriptor>
82-
fromNode(const hipdnn_data_sdk::data_objects::NodeT& nodeT,
83+
fromNode(const hipdnn_flatbuffers_sdk::data_objects::NodeT& nodeT,
8384
const std::unordered_map<int64_t, std::shared_ptr<TensorDescriptor>>& tensorMap);
8485

8586
static hipdnnBackendDescriptorType_t getStaticType();
8687

8788
std::string toString() const override;
8889

8990
private:
90-
hipdnn_data_sdk::data_objects::BatchnormInferenceAttributesVarianceExtT _data;
91+
hipdnn_flatbuffers_sdk::data_objects::BatchnormInferenceAttributesVarianceExtT _data;
9192

9293
// Store tensor descriptor references for validation and graph building
9394
std::shared_ptr<TensorDescriptor> _xDesc;
@@ -99,8 +100,8 @@ class BatchnormInferenceVarianceExtOperationDescriptor
99100
std::shared_ptr<TensorDescriptor> _epsilonDesc;
100101

101102
// Compute data type for this operation (stored at node level in graph)
102-
hipdnn_data_sdk::data_objects::DataType _computeDataType
103-
= hipdnn_data_sdk::data_objects::DataType::UNSET;
103+
hipdnn_flatbuffers_sdk::data_objects::DataType _computeDataType
104+
= hipdnn_flatbuffers_sdk::data_objects::DataType::UNSET;
104105

105106
std::string _name;
106107
};

0 commit comments

Comments
 (0)