tf.cumsum / tf.cumprod with a negative axis return a tensor of shape [undefined, ...] (cpu) or crash (wasm)

Đang mở Phù hợp với người mới
#8,754 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, typescript, wasm
Lĩnh vực
backend, machine-learning

Hướng nghiên cứu

Bắt đầu với tfjs-core/src/ops/cumsum.ts và cumprod.ts, sau đó kiểm tra các kernel CPU và WASM truyền [axis] vào getAxesPermutation. So sánh cách các ops khác chuẩn hóa trục bằng parseAxisParam và kiểm tra các bài kiểm thử hiện có cho tổng tích lũy và tích tích lũy. Công việc hoàn tất khi trục âm tạo ra kết quả khớp với trục dương tương ứng trên cả hai backend hoặc gây ra lỗi xác thực rõ ràng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Please make sure that this is a bug. As per our
GitHub Policy,
we only address code/doc bugs, performance issues, feature requests and
build/installation issues on GitHub. tag:bug_template

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux x86_64 (Debian 12)
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: n/a
  • TensorFlow.js installed from (npm or script link): npm
  • TensorFlow.js version (use command below): @tensorflow/tfjs-core, @tensorflow/tfjs-backend-cpu, @tensorflow/tfjs-backend-wasm 4.22.0 (master 7f5309fe unchanged), Node.js v26.13.0
  • Browser version: n/a
  • Tensorflow.js Converter Version: n/a

Describe the current behavior

tf.cumsum(x, -1) and tf.cumprod(x, -1) do not normalize or validate a negative axis. On the cpu backend, the returned tensor has shape [undefined, 2] and empty data []. On the wasm backend, the call aborts with RuntimeError: memory access out of bounds inside Module._free. Most other tfjs ops accept negative axes via parseAxisParam, as does TensorFlow's tf.math.cumsum.

Describe the expected behavior

Compute the cumulative sum or product along the last axis ([[1, 3, 6], [4, 9, 15]] for the example below, matching tf.cumsum(x, 1)), or throw a validation error if negative axes are not supported.

Standalone code to reproduce the issue

const tf = require("@tensorflow/tfjs-core");
require("@tensorflow/tfjs-backend-cpu");
require("@tensorflow/tfjs-backend-wasm");
(async () => {
  await tf.setBackend(process.argv[2]);
  const x = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]);
  const y = tf.cumsum(x, -1);
  console.log(y.shape, Array.from(y.dataSync()));
})();
$ node cumsum.js cpu
[ undefined, 2 ] []
$ node cumsum.js wasm
RuntimeError: memory access out of bounds

Other info / logs

tfjs-core/src/ops/cumsum.ts and cumprod.ts pass axis directly to the kernel without calling parseAxisParam, and the cpu and wasm kernels pass [axis] directly to getAxesPermutation([axis], rank).

Credit: https://ucsbplse.github.io/

Ngôn ngữ chính
TypeScript
Star
19.2k
Fork
2k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của tensorflow/tfjs

Tất cả issue của tensorflow/tfjs

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.