Skip to content

Commit

Permalink
[WIP]
Browse files Browse the repository at this point in the history
Signed-off-by: Michał Zientkiewicz <mzient@gmail.com>
  • Loading branch information
mzient committed Jan 17, 2025
1 parent 4421ace commit 41b2ebc
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions dali/c_api_2/data_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ class TensorListInterface : public RefCountedObject {
virtual cudaEvent_t GetOrCreateReadyEvent() = 0;
};

struct TensorListDeleter {
daliDeleter_t deleter;
AccessOrder deletion_order;

void operator()(void *data) {
if (deleter.delete_buffer) {
cudaStream_t stream = deletion_order.stream();
deleter.delete_buffer(deleter.deleter_ctx, data,
deletion_order.is_device() ? &stream : nullptr);
}
if (deleter.destroy_context) {
deleter.destroy_context(deleter.destroy_context);
}
}
};

template <typename Backend>
class TensorListWrapper : public TensorListInterface {
public:
Expand Down Expand Up @@ -91,10 +107,7 @@ class TensorListWrapper : public TensorListInterface {
if (!deleter.delete_buffer && !deleter.destroy_context) {
buffer.reset(buffer, [](void *){});
} else {
buffer.reset(buffer, [deleter](void *p) {
if (deleter.delete_buffer)
deleter.delete_buffer(deleter.deleter_ctx, p, nullptr);
});
buffer.reset(buffer, TensorListDeleter{deleter, order()});
}
for (int i = 0; i < num_samples; i++) {
TensorShape<> sample_shape(make_cspan(&shapes[i*ndim]. ndim));
Expand All @@ -105,17 +118,17 @@ class TensorListWrapper : public TensorListInterface {
sample_data = static_cast<char *>(data) + next_offset;
next_offset += volme(sample_shape) * element_size;
}

}

}

virtual void AttachSamples(
int num_samples,
int ndim,
daliDataType_t dtype,
const daliTensorDesc_t *samples,
const daliDeleter_t *sample_deleters) = 0;
const daliDeleter_t *sample_deleters) {

}

virtual daliBufferPlacement_t GetBufferPlacement() const = 0;

Expand Down

0 comments on commit 41b2ebc

Please sign in to comment.