Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bindings for views (or xstrided_views) #130

Open
@tarcisiofischer

Description

@tarcisiofischer

I was trying to get an array view from cpp and call a python function back with it.
After some help, I managed to do it by converting the view to axt::pytensor before proceeding with the Python call (See code below).

voidcpp_f(xt::pytensor<double,2> my_arr, py::object py_f) {auto v = xt::pytensor<double,1>(xt::view(my_arr,0,xt::all()));py_f(v);}
deftest_view():defpy_f(v):print(v)cpp_f(np.array([ [1,2,3], [4,5,6], ]),py_f)

It would be nice to have some way to pass the view directly to the python function, instead of having to convert them. It seems that it is not possible to make bindings forxt::view directly, though. I'll leave the original discussion here for reference:

Tarcísio Fischer @tarcisiofischer 14:49Do you know if there'll be bindings for the xt::view anytime soon?Johan Mabille @JohanMabille 14:50the thing is numpy view and xtensor views are not exactly the same so we cannot bind view directlySylvain Corlay @SylvainCorlay 14:50Not as a numpy array, but there is some hope for strided views on pyarrays / pytensor.Johan Mabille @JohanMabille 14:50we have xstrided_views that works like numpy views, we can make bindings for them

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp