Skip to content

fix : Tensor toString() and capacity() when implementation is undefined

Christophe Guillon requested to merge fix_tensor_with_no_impl into dev

Context

As reported in issue #201 (closed) the toString() method when a tensor has no implementation generates an assertion, actually the assertion itself is incorrect as it is not correctly formated due to the presence of '{}' misinterpreted by the fmt library.

Though, actually I propose to have toString() always return a valid string instead of asserting, i.e.:

  • when the tensor as no impl: return {}
  • when the tensor is undefined (i.e. no defined size): return {} also

This fixes the mentioned issue, but more importantly avoids assertion in a string representation which I guess is what we should expect.

Also it avoids specific case in the python binding for str() which actually attempted to avoid these corner cases.

Note that while I was inspecting the python bindings I also detected an issue with the capacity() method which segfaults when the tensor as no implementation. I fixes this also conservatively, and choose to return 0 when no implmentation is given for the tensor.

Hence the two commits proposed.

Modified files

Refer to commits review:

  • fix : Tensor assertion with no implementation on toString()
  • fix : Tensor invalid impl on call to capacity()

Detailed major modifications

Now tensor toString return '{}' on : !hasImpl() || undefined() instead of ASSERTING

This does not change the python binding for str() which already returned {}.

TODO

None

Merge request reports

Loading