MCPcopy Create free account
hub / github.com/NVIDIA/DALI / MakeTestDeleter

Function MakeTestDeleter

dali/c_api_2/data_objects_test.cc:164–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162
163template <typename element_t>
164inline std::pair<daliDeleter_t, std::unique_ptr<TestDeleterCtx>>
165MakeTestDeleter(element_t *expected_data) {
166 auto ctx = std::unique_ptr<TestDeleterCtx>(new TestDeleterCtx{ expected_data, 0, 0 });
167 daliDeleter_t deleter = {};
168 deleter.deleter_ctx = ctx.get();
169 deleter.delete_buffer = [](void *vctx, void *data, const cudaStream_t *stream) {
170 ASSERT_NE(data, nullptr);
171 auto *ctx = static_cast<TestDeleterCtx *>(vctx);
172 EXPECT_EQ(ctx->context_delete_count, 0);
173 EXPECT_EQ(ctx->buffer_delete_count, 0);
174 EXPECT_EQ(data, ctx->expected_data);
175 ctx->buffer_delete_count++;
176 // do not actually delete the data
177 };
178 deleter.destroy_context = [](void *vctx) {
179 auto *ctx = static_cast<TestDeleterCtx *>(vctx);
180 EXPECT_EQ(ctx->context_delete_count, 0);
181 EXPECT_EQ(ctx->buffer_delete_count, 1);
182 ctx->context_delete_count++;
183 };
184 return { deleter, std::move(ctx) };
185}
186
187TEST(CAPI2_TensorListTest, AttachBuffer) {
188 daliBufferPlacement_t placement{};

Callers 1

TESTFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected