cupy.testing.numpy_cupy_array_equal#

cupy.testing.numpy_cupy_array_equal(err_msg='', verbose=True, name='xp', type_check=True, accept_error=False, sp_name=None, scipy_name=None, strides_check=False)[source]#

一个装饰器,用于检查 NumPy 和 CuPy 的结果是否相等。

参数:
  • err_msg (str) – 失败时打印的错误消息。

  • verbose (bool) – 如果为 True,则冲突的值将附加到错误消息中。

  • name (str) – 参数名称,其值可以是 numpycupy 模块。

  • type_check (bool) – 如果为 True,则还会检查 dtype 的一致性。

  • accept_error (bool, Exceptiontuple of Exception) – 指定可接受的错误。当 NumPy 测试和 CuPy 测试都引发相同类型的错误,并且该错误类型通过此参数指定时,将忽略这些错误,不会引发。如果为 True,则所有错误类型都可接受。如果为 False,则不接受任何错误。

  • sp_name (strNone) – 参数名称,其值可以是 scipy.sparsecupyx.scipy.sparse 模块。如果为 None,则不为这些模块提供参数。

  • scipy_name (strNone) – 参数名称,其值可以是 scipycupyx.scipy 模块。如果为 None,则不为这些模块提供参数。

  • strides_check (bool) – 如果为 True,则还会检查 strides 的一致性。

被装饰的测试夹具(test fixture)需要在 xpnumpycupy 时,返回与 numpy_cupy_array_equal() 意义上相同的数组(数组模块类型除外)。