data.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2019-2025, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
8 namespace MLCommon {
9 namespace Matrix {
10 
17 template <typename Type>
18 struct Data {
19  Data() : ptr(nullptr), totalSize(0) {}
20  Data(Type* _ptr, size_t _n_elements) : ptr(_ptr), totalSize(_n_elements * sizeof(Type)) {}
21 
26  Type* ptr = nullptr;
27 
32  size_t totalSize = (size_t)0;
33 
37  size_t numElements() const { return totalSize / sizeof(Type); }
38 };
39 
42 
43 }; // end namespace Matrix
44 }; // end namespace MLCommon
Data< double > doubleData_t
Definition: data.hpp:41
Data< float > floatData_t
Definition: data.hpp:40
Definition: comm_utils.h:11
This is a helper wrapper around the multi-gpu data blocks owned by a worker. It's design is NOT final...
Definition: data.hpp:18
size_t totalSize
Definition: data.hpp:32
Data(Type *_ptr, size_t _n_elements)
Definition: data.hpp:20
Data()
Definition: data.hpp:19
size_t numElements() const
Definition: data.hpp:37
Type * ptr
Definition: data.hpp:26