Giter VIP home page Giter VIP logo

Comments (3)

VivekPanyam avatar VivekPanyam commented on May 18, 2024 1

Put up a fix in #399. Thanks again for the detailed bug report and repro!

from neuropod.

VivekPanyam avatar VivekPanyam commented on May 18, 2024

Thanks for the bug report and the repro script!

I'm pretty sure this behavior is because of this TODO:

std::shared_ptr<NeuropodTensor> tensor_from_numpy(NeuropodTensorAllocator &allocator, py::array array)
{
// TODO(vip): Make sure it's contiguous and aligned
auto ndims = array.ndim();
auto dims = array.shape();
auto dtype = get_array_type(array);
auto data = array.mutable_data();
// Capture the array in our deleter so it doesn't get deallocated
// until we're done
auto to_delete = std::make_shared<py::array>(array);
auto deleter = [to_delete](void *unused) mutable {
py::gil_scoped_acquire gil;
to_delete.reset();
};
// Create a vector with the shape info
std::vector<int64_t> shape(&dims[0], &dims[ndims]);
if (dtype != STRING_TENSOR)
{
// Wrap the data from the numpy array
return allocator.tensor_from_memory(shape, dtype, data, deleter);
}
else
{
return tensor_from_string_numpy(allocator, array, shape);
}
}

In addition to fixing that TODO (ensure contiguous and aligned), I also want to look into correctly propagating the strides through into Neuropod.

Unfortunately, there are many cases where we depend (or need to depend) on data being contiguous so I'm not sure whether propagating the stride information will be worth it (if we always need to convert into a contiguous tensor later for example). I'll create another issue about this to describe some of the pros and cons.

Thanks again for the detailed bug report!

from neuropod.

dsuess avatar dsuess commented on May 18, 2024

That TODO does look pretty much on point :D

Maybe it's worth just putting in a error for now if the data is not contiguous. It took me a while to figure out because the testcase run in create_python_neuropod passes. If a user is alerted when the neuropod is created, it's pretty easy to fix.

from neuropod.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.