Giter Club home page Giter Club logo

Comments (2)

JoOkuma avatar JoOkuma commented on June 18, 2024 1

Making a copy and updating the docs to say it's not in place would be excellent!
Thanks for the quick reply @kmaehashi

from cupy.

kmaehashi avatar kmaehashi commented on June 18, 2024

Thanks for reporting @JoOkuma! The shift operation (and many ndimage features) rely on raw CUDA kernel generated on-the-fly. I haven't fully checked the code but it looks it does not support cases s.t. input and output memory overlap.

Supporting in-place will need almost full rewrite of the kernel so I'm thinking of adding a check and making a copy automatically if there is an overlap.

output = _util._get_output(output, input)
if input.dtype.kind in 'iu':
input = input.astype(cupy.float32)
filtered, nprepad = _filter_input(input, prefilter, mode, cval, order)
integer_output = output.dtype.kind in 'iu'
_util._check_cval(mode, cval, integer_output)
large_int = _prod(input.shape) > 1 << 31
kern = _interp_kernels._get_shift_kernel(
input.ndim, large_int, input.shape, mode, cval=cval, order=order,
integer_output=integer_output, nprepad=nprepad)
shift = cupy.asarray(shift, dtype=cupy.float64, order='C')
if shift.ndim != 1:
raise ValueError('shift must be 1d')
if shift.size != filtered.ndim:
raise ValueError('len(shift) must equal input.ndim')
kern(filtered, shift, output)

from cupy.

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.