MCPcopy Index your code
hub / github.com/NVIDIA/warp / flatten

Method flatten

warp/_src/types.py:4244–4267  ·  view source on GitHub ↗

Return a zero-copy view of the array collapsed to 1-D. Only supported for contiguous arrays.

(self)

Source from the content-addressed store, hash-verified

4242 return warp.clone(self, device=device, requires_grad=requires_grad)
4243
4244 def flatten(self):
4245 """Return a zero-copy view of the array collapsed to 1-D. Only supported for contiguous arrays."""
4246 if self.ndim == 1:
4247 return self
4248
4249 if not self.is_contiguous:
4250 raise RuntimeError("Flattening non-contiguous arrays is unsupported.")
4251
4252 a = array(
4253 ptr=self.ptr,
4254 dtype=self.dtype,
4255 shape=(self.size,),
4256 device=self.device,
4257 pinned=self.pinned,
4258 copy=False,
4259 grad=None if self.grad is None else self.grad.flatten(),
4260 )
4261
4262 # transfer read flag
4263 a._is_read = self._is_read
4264
4265 # store back-ref to stop data being destroyed
4266 a._ref = self
4267 return a
4268
4269 def reshape(self, shape):
4270 """Return a reshaped array. Only supported for contiguous arrays.

Callers 15

test_viewsFunction · 0.80
gradcheckFunction · 0.80
test_flattenFunction · 0.80
test_slicingFunction · 0.80
test_full_matrixFunction · 0.80
test_empty_opsFunction · 0.80
assert_np_equalFunction · 0.80
test_bsr_mvFunction · 0.80
test_bsr_multiply_deepFunction · 0.80
test_array_innerFunction · 0.80
test_mesh_query_ray_gradFunction · 0.80

Calls 1

arrayClass · 0.85

Tested by 15

test_viewsFunction · 0.64
gradcheckFunction · 0.64
test_flattenFunction · 0.64
test_slicingFunction · 0.64
test_full_matrixFunction · 0.64
test_empty_opsFunction · 0.64
assert_np_equalFunction · 0.64
test_bsr_mvFunction · 0.64
test_bsr_multiply_deepFunction · 0.64
test_array_innerFunction · 0.64
test_mesh_query_ray_gradFunction · 0.64