NNFloatData
class NNFloatData : public NNData
{
public:
static std::shared_ptr<NNFloatData> createData(uint32_t dataSize);
static std::shared_ptr<NNFloatData> createData(void* data, uint32_t dataSize);
static std::shared_ptr<NNFloatData> createData(std::shared_ptr<NNRawData> rawData);
public:
void* getData();
uint32_t getDataSize();
public:
virtual std::string getType();
virtual std::string toString();
virtual std::shared_ptr<NNData> clone(bool deep);
};
Introduction to the class
A class representing floating-point data within a neural network.
This class inherits from NNData and provides specific implementations for handling floating-point data. It includes methods for creating data instances, accessing the data, and fulfilling the virtual functions defined in the base class.
Introduction to the Class's Methods
static std::shared_ptr<NNFloatData> createData(uint32_t dataSize)
brief: Creates a new instance of NNFloatData with a specified data size. This method allocates memory for the floating-point data based on the provided size.
param
dataSize: The size of the data to allocate, in number of floating-point values.
return shared_ptr<NNFloatData>: A shared pointer to the created data instance.
static std::shared_ptr<NNFloatData> createData(void* data, uint32_t dataSize)
brief: Creates a new instance of NNFloatData from existing data. This method takes a pointer to existing data and its size, wraps it in an NNFloatData instance.
param
data: A pointer to the existing data. It should be noted that the content of the data parameter will be deep-copied into its internal properties.
dataSize: The size of the data, in number of floating-point values.
return shared_ptr<NNFloatData>: A shared pointer to the created data instance.
static std::shared_ptr<NNFloatData> createData(std::shared_ptr<NNRawData> rawData)
brief: Creates a new instance of NNFloatData from a shared pointer to raw data. This method takes a shared pointer to NNRawData and wraps it in an NNFloatData instance.
param
rawData: A shared pointer to the raw data. It should be noted that the passed-in parameter rawData will be referenced by this object.
return shared_ptr<NNFloatData>: A shared pointer to the created data instance.
void* getData()
brief: Gets a pointer to the internal data. This method returns a pointer to the internal floating-point data.
return void*: A pointer to the internal data.
uint32_t getDataSize()
brief: Gets the size of the internal data. This method returns the size of the internal floating-point data, in number of values.
return uint32_t: The size of the data.
std::string getType()
brief: Gets the type of the data. This method returns a string representing the type of the data.
return string: A string representing the data type.
std::string toString()
brief: Converts the data object to a string representation. This method returns a string that describes the data object, including its type and values.
return string: A string representation of the data object.
std::shared_ptr<NNData> clone(bool deep)
brief: Clones the data object. This method creates a deep or shallow copy of the data object, depending on the value of the `deep` parameter.
param
deep: A boolean indicating whether to perform a deep clone.
return shared_ptr<NNData>: A shared pointer to the cloned data object.