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

Aperta
#1,960 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python

Direzione di ricerca

Iniziare con il decoratore @script, le annotazioni FLOAT e le espressioni degli operatori nell’esempio model_1 fornito; riprodurre l’errore relativo all’operando sinistro non supportato con le versioni dei pacchetti indicate. Tracciare la gestione di FLOAT, dei valori float32 di NumPy, di Constant e dei normali operatori aritmetici, quindi documentare o testare le conversioni e le forme delle espressioni supportate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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)
Lingua principale
Python
Stelle
457
Fork
149
Merge medio
3g 20h
PR unite (30g)
22

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/onnxscript

Tutte le issue di microsoft/onnxscript

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.