Conversation
|
CI MESSAGE: [45989005]: BUILD STARTED |
Greptile SummaryThis PR adds programmatic pipeline building to the C API, providing C-callable counterparts to the C++ Key points:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant C as C Caller
participant API as C API (pipeline.cc)
participant Val as Validate (validation.h)
participant Pipe as Pipeline (C++)
C->>API: daliPipelineCreate(&h, ¶ms)
API->>Pipe: new Pipeline(params)
Pipe-->>API: pipeline object
API-->>C: daliPipeline_h
C->>API: daliPipelineAddExternalInput(h, &input_desc)
API->>Val: Validate(*input_desc)
Val-->>API: ok / throws
API->>Pipe: AddExternalInput(name, device, dtype, ndim, layout)
C->>API: daliPipelineAddOperator(h, &op_desc)
API->>API: MakeOpSpec(op_desc)
Note over API: Validates counts, nulls, backend<br/>Builds OpSpec with inputs/outputs/<br/>args/arg_inputs
API->>Val: Validate(device_type) per I/O
Val-->>API: ok / throws
API->>Pipe: AddOperator(spec [, instance_name])
C->>API: daliPipelineSetOutputs(h, n, outputs)
API->>Val: Validate(outputs[i]) per output
Val-->>API: ok / throws
API->>Pipe: SetOutputDescs(descs)
C->>API: daliPipelineBuild(h)
API->>Pipe: Build()
Pipe-->>API: ready
API-->>C: DALI_SUCCESS
Last reviewed commit: 681bc56 |
|
CI MESSAGE: [46046566]: BUILD STARTED |
4f37b46 to
14c69cd
Compare
|
CI MESSAGE: [46051079]: BUILD STARTED |
|
CI MESSAGE: [46064404]: BUILD STARTED |
|
CI MESSAGE: [46065411]: BUILD STARTED |
| case DALI_INT_VEC: { | ||
| check_arr(); | ||
| auto *d = static_cast<const int *>(arg.arr); | ||
| spec.AddArg(name, std::vector<int>(d, d + arg.size)); | ||
| break; | ||
| } | ||
| case DALI_FLOAT_VEC: { | ||
| check_arr(); | ||
| auto *d = static_cast<const float *>(arg.arr); | ||
| spec.AddArg(name, std::vector<float>(d, d + arg.size)); | ||
| break; | ||
| } | ||
| case DALI_BOOL_VEC: { | ||
| check_arr(); | ||
| auto *d = static_cast<const bool *>(arg.arr); | ||
| spec.AddArg(name, std::vector<bool>(d, d + arg.size)); | ||
| break; |
There was a problem hiding this comment.
Null-pointer arithmetic UB for zero-size vector args
When arg.size == 0 and arg.arr == nullptr (a valid combination — check_arr() only requires non-NULL when arg.size > 0), the expression d + arg.size where d == nullptr performs pointer arithmetic on a null pointer. This is technically undefined behaviour under the C++14/17 standard (a pointer must point to an array element or one-past-the-end to support arithmetic). In practice all major compilers produce correct code for nullptr + 0, but the UB could be silently miscompiled under aggressive optimisation.
The same issue exists on the equivalent lines for DALI_FLOAT_VEC (line 602) and DALI_BOOL_VEC (line 607).
A minimal fix is to guard the vector constructor call, matching the pattern already used for DALI_STRING_VEC:
case DALI_INT_VEC: {
check_arr();
auto *d = static_cast<const int *>(arg.arr);
spec.AddArg(name, arg.size > 0 ? std::vector<int>(d, d + arg.size)
: std::vector<int>());
break;
}Or equivalently, skip the pointer arithmetic entirely when the size is zero.
|
CI MESSAGE: [46065411]: BUILD FAILED |
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
…guments. Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
c493a73 to
681bc56
Compare
|
CI MESSAGE: [46347401]: BUILD STARTED |
|
CI MESSAGE: [46347401]: BUILD PASSED |
Category:
New feature (non-breaking change which adds functionality)
Description:
This PR adds an ability to build pipelines in C API by defining operator descriptors and adding those to the pipeline via
daliPipelineAddOperator.Additional information:
Affected modules and functionalities:
Key points relevant for the review:
Tests:
Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: N/A