Skip to content

[IMPR] getImpl() returns a reference

laurent soulier requested to merge feat/RefGetImpl into main

Making Tensor::getImpl() return a reference to a TensorImpl.

On "client" side it displays the guarantee that an implementation is actually returned whereas returning a pointer (even a smart one) leaves the risk of a null one.

(In order to go further, Tensor::getImpl() should check itself the validity of the implementation and call AIDGE_THROW_OR_ABORT itself).

Beside I couldn't see a valid reason to return a reference to std::unique_ptr

  • NB1 used in !13 (closed) where std::unique_ptr is replaced by a std::shared_ptr. In this case, it is debatable if a shared or weak pointer should be returned instead of a plain reference.
  • NB2 merging this MR will make !13 (closed) simpler to merge.
Edited by Maxence Naud

Merge request reports