flopscope.

flopscope.numpy.may_share_memory

fnp.may_share_memory(*args, **kwargs)[flopscope source]

Determine if two arrays might share memory

Adapted from NumPy docs np.may_share_memory

Areacore
Typefree
Cost
0
Flopscope Context

Determine if two arrays might share memory.

A return of True does not necessarily mean that the two arrays share any element. It just means that they might.

Only the memory bounds of a and b are checked by default.

Parameters

a, b:ndarray

Input arrays

max_work:int, optional

Effort to spend on solving the overlap problem. See shares_memory for details. Default for may_share_memory is to do a bounds check.

Returns

out:bool

See also

Examples

>>> import flopscope.numpy as fnp
>>> flops.may_share_memory(flops.array([1,2]), flops.array([5,8,9]))
False
>>> x = flops.zeros([3, 4])
>>> flops.may_share_memory(x[:,0], x[:,1])
True