ABD
ABD

Reputation: 300

Doing python numpy similar operation in cpp xtensor

I am converting some python numpy code into C++ code using xtensor library. I am having some issues in indexing based operations. Here is the python code:

Python code

boxes = decoded_boxes[keep, :]

I am not able to write equivalent code for this. I tried this but did not work.

C++ code

xt::xarray<float> b1 = xt::filter(decoded_boxes, keep); 
std::cout << "b1 shape = " << xt::adapt(b1.shape()) << std::endl; 

gives only {24}.

Upvotes: 1

Views: 195

Answers (1)

ABD
ABD

Reputation: 300

I was able to work around as follows:

auto id = xt::arange(decoded_boxes.shape()[0]);
auto b2 = xt::filter(id, keep);
    
xt::xarray<float> b1 = xt::view(decoded_boxes, xt::keep(b2)); // shape 24, 4

Upvotes: 1

Related Questions