jax.experimental.sparse.bcoo_update_layout#

jax.experimental.sparse.bcoo_update_layout(mat, *, n_batch=None, n_dense=None, on_inefficient='error')[原始碼]#

更新 BCOO 矩陣的儲存佈局 (即 n_batch & n_dense)。

在許多情況下,這可以在不引入不必要的儲存額外負荷的情況下完成。但是,增加 mat.n_batchmat.n_dense 將導致非常低效的儲存,其中包含許多顯式儲存的零,除非新的批次或密集維度的大小為 0 或 1。在這種情況下,bcoo_update_layout 將引發 SparseEfficiencyErroron_inefficient 參數可以靜音此錯誤。

參數:
  • mat (BCOO) – BCOO 陣列

  • n_batch (int | None | None) – optional(int) 輸出矩陣中的批次維度數。如果為 None,則 n_batch = mat.n_batch。

  • n_dense (int | None | None) – optional(int) 輸出矩陣中的密集維度數。如果為 None,則 n_dense = mat.n_dense。

  • on_inefficient (str | None) – optional(string),選項為 ['error', 'warn', None] 之一。指定在無效率重新配置的情況下的行為。這被定義為重新配置,其中結果表示的大小遠大於輸入表示的大小。

回傳值:

BCOO 陣列

一個 BCOO 陣列,表示與輸入相同的稀疏陣列,具有指定的佈局。mat_out.todense() 將匹配 mat.todense(),精確度適當。

回傳類型:

mat_out