SWDEV-313082 - hipGraphMemsetNodeSetParams invalid params

Change-Id: Ibe57df8d7d583daf9ba9c7a86863eacca4868f3a
This commit is contained in:
Ajay
2022-01-21 23:50:18 +00:00
committed by Ajay GunaShekar
parent 0440d945e8
commit cb79dc7486
4 changed files with 35 additions and 2 deletions
+4
View File
@@ -122,6 +122,10 @@ hipError_t ihipGraphAddMemsetNode(hipGraphNode_t* pGraphNode, hipGraph_t graph,
return hipErrorInvalidValue;
}
hipError_t status;
status = ihipGraphMemsetParams_validate(pMemsetParams);
if (status != hipSuccess) {
return status;
}
if (pMemsetParams->height == 1) {
status =
ihipMemset_validate(pMemsetParams->dst, pMemsetParams->value, pMemsetParams->elementSize,
+2
View File
@@ -86,3 +86,5 @@ hipError_t ihipMemcpyAtoHValidate(hipArray* srcArray, void* dstHost, amd::Coord3
amd::Coord3D& dstOrigin, amd::Coord3D& copyRegion,
size_t dstRowPitch, size_t dstSlicePitch, amd::Image*& srcImage,
amd::BufferRect& dstRect);
hipError_t ihipGraphMemsetParams_validate(const hipMemsetParams* pNodeParams);
+15 -2
View File
@@ -811,9 +811,22 @@ class hipGraphMemsetNode : public hipGraphNode {
std::memcpy(params, pMemsetParams_, sizeof(hipMemsetParams));
}
hipError_t SetParams(const hipMemsetParams* params) {
hipError_t hip_error = hipSuccess;
hip_error = ihipMemset_validate(params->dst, params->value, params->elementSize,
params->width * params->elementSize);
hip_error = ihipGraphMemsetParams_validate(params);
if (hip_error != hipSuccess) {
return hip_error;
}
if (params->height == 1) {
hip_error = ihipMemset_validate(params->dst, params->value, params->elementSize,
params->width * params->elementSize);
} else {
auto sizeBytes = params->width * params->height * 1;
hip_error = ihipMemset3D_validate(
{params->dst, params->pitch, params->width, params->height},
params->value, {params->width, params->height, 1}, sizeBytes);
}
if (hip_error != hipSuccess) {
return hip_error;
}
+14
View File
@@ -2276,6 +2276,20 @@ hipError_t ihipMemset_validate(void* dst, int64_t value, size_t valueSize,
return hipSuccess;
}
hipError_t ihipGraphMemsetParams_validate(const hipMemsetParams* pNodeParams) {
if (pNodeParams == nullptr) {
return hipErrorInvalidValue;
}
if (pNodeParams->elementSize != 1 && pNodeParams->elementSize != 2 && pNodeParams->elementSize != 4) {
return hipErrorInvalidValue;
}
if (pNodeParams->height <= 0) {
return hipErrorInvalidValue;
}
return hipSuccess;
}
hipError_t ihipMemsetCommand(std::vector<amd::Command*>& commands, void* dst, int64_t value,
size_t valueSize, size_t sizeBytes, amd::HostQueue* queue) {
hipError_t hip_error = hipSuccess;