cppflow icon indicating copy to clipboard operation
cppflow copied to clipboard

How to index cppflow::tensor data.

Open edargham opened this issue 3 years ago • 1 comments

I'm trying to implement the non-max suppression algorithm on the raw output generated by the YOLOv5 model I trained and loaded into my C++ cppflow model instance.

To extract the candidate bounding boxes in python we must perform this operation

    .
    .
    .
    candidates = predictions[..., 4]
    .
    .
    .

I did not find any way I can access the internal data of the cppflow::tensors. The only way is to extract it into an std::vector<T> using tensor.get_data<T>(). Then rearranging the dumped output into the desired shape.

I have no qualms doing this, however I do worry about the performance cost of this approach.

It would be wonderful if we could directly query the tensor object to and access the desired indeces using the [] operator. Is there no alternative approach to the one I mentioned that is less costly?

edargham avatar Oct 06 '22 12:10 edargham

Have you tried using the cppflow::slice operator?

yochananscharf avatar Oct 25 '22 13:10 yochananscharf