Unsupported left operand type for - ("FLOAT") [operator]

Đang mở
#1,960 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 4 ngày

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

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
machine-learning

Hướng nghiên cứu

Bắt đầu với decorator @script, các chú thích FLOAT và các biểu thức toán tử trong ví dụ model_1 được cung cấp; tái hiện lỗi toán hạng bên trái không được hỗ trợ với các phiên bản package được liệt kê. Theo dõi cách FLOAT, các giá trị float32 của NumPy, Constant và các toán tử số học thông thường được xử lý, đồng thời ghi lại hoặc kiểm thử các chuyển đổi và dạng biểu thức được hỗ trợ.

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

Mô tả

category: question

Hi everyone, I am trying to use onnxscript to convert a function into a script via the @script decorator. I have two questions:

  1. Is there any ways to do subtraction between an input with the FLOAT type and the input with np.float32? If not, how do I convert from one to the other (I have looked up ALL the possible documentations from onnx but it's not much helpful). Right now I keep getting the error error: Unsupported left operand type for - ("FLOAT") [operator] with note: Right operand is of type "BFLOAT16 | BOOL | COMPLEX128 | COMPLEX64 | DOUBLE | <11 more items>"
  2. Can I still use the normal operator (e.g. +, -, :, *) to do addition/subtraction/division/multiplication within the function that is supposed to be rewritten into .onnx model? The reason I ask is because it looks like onnxscript needs data to be of TensorType?

Package versions. onnxscript = 0.1.0.dev2024112, onnx=1.17.0, onnxconverter-common=1.13.0, onnxruntime=1.20.0, skl2onnx=1.17.0

Example.

         import numpy as np
         import onnx
         import pandas as pd
         from onnxscript import FLOAT
         from onnxscript import opset15 as op
        from onnxscript import script      
        z1 = 5.0
        z2 = 3.0
        t1 = z1.astype('np.float32')
        t2 = z2.astype('np.float32')
        cum_mins = [1,2,3,4]
        @script()
        def model_1(x: FLOAT, y: FLOAT) -> Tuple[Any, Any]:
            # Define constants
            coeff1 = op.Constant(value_float=t1)
            coeff2 = op.Constant(value_float=t2)

            mean_x = op.Constant(value_float=x)
            mean_y = op.Constant(value_float=y)

            exp_arg = coeff1 * (x - mean_x) + coeff2 * (y - mean_y)    
            exp = op.Constant(value_float=0.75) * op.Exp(exp_arg)

            h = op.Constant(value_floats=cum_mins)

            return (exp, h)
Ngôn ngữ chính
Python
Star
457
Fork
149
Merge trung bình
3 ngày 20 giờ
Pull request đã merge (30 ngày)
22

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 microsoft/onnxscript

Tất cả issue của microsoft/onnxscript

Issue tương tự

Thêm issue về Python

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.