MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / ndarray

Class ndarray

Source/Falcor/Utils/Scripting/ndarray.h:366–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

364
365template<typename... Args>
366class ndarray
367{
368public:
369 using Info = detail::ndarray_info<Args...>;
370 using Scalar = typename Info::scalar_type;
371
372 ndarray() = default;
373
374 explicit ndarray(detail::ndarray_handle* handle) : m_handle(handle)
375 {
376 if (handle)
377 m_dltensor = *detail::ndarray_inc_ref(handle);
378 }
379
380 ndarray(
381 void* value,
382 size_t ndim,
383 const size_t* shape,
384 handle owner = pybind11::handle(),
385 const int64_t* strides = nullptr,
386 dlpack::dtype dtype = pybind11::dtype<Scalar>(),
387 int32_t device_type = device::cpu::value,
388 int32_t device_id = 0
389 )
390 {
391 m_handle = detail::ndarray_create(value, ndim, shape, owner.ptr(), strides, &dtype, device_type, device_id);
392 m_dltensor = *detail::ndarray_inc_ref(m_handle);
393 }
394
395 ~ndarray() { detail::ndarray_dec_ref(m_handle); }
396
397 ndarray(const ndarray& t) : m_handle(t.m_handle), m_dltensor(t.m_dltensor) { detail::ndarray_inc_ref(m_handle); }
398
399 ndarray(ndarray&& t) noexcept : m_handle(t.m_handle), m_dltensor(t.m_dltensor)
400 {
401 t.m_handle = nullptr;
402 t.m_dltensor = dlpack::dltensor();
403 }
404
405 ndarray& operator=(ndarray&& t) noexcept
406 {
407 detail::ndarray_dec_ref(m_handle);
408 m_handle = t.m_handle;
409 m_dltensor = t.m_dltensor;
410 t.m_handle = nullptr;
411 t.m_dltensor = dlpack::dltensor();
412 return *this;
413 }
414
415 ndarray& operator=(const ndarray& t)
416 {
417 detail::ndarray_inc_ref(t.m_handle);
418 detail::ndarray_dec_ref(m_handle);
419 m_handle = t.m_handle;
420 m_dltensor = t.m_dltensor;
421 return *this;
422 }
423

Callers

nothing calls this directly

Calls 3

ndarray_dec_refFunction · 0.85
dltensorClass · 0.85
ndarray_inc_refFunction · 0.85

Tested by

no test coverage detected