Skip to content

TYPE-ERROR in basic operations if types differ #173

Open
@stewart123579

Description

@stewart123579

I'm not even convinced this is a bug or appropriate behaviour...

Depending on the order of arguments we can get a type-error from [the setf] (https://github.com/quil-lang/magicl/blob/master/src/high-level/abstract-tensor.lisp#L197=) in binary-operator

(defparameter int-tensor (magicl:from-list '(1 2 3) '(3)))
(defparameter float-tensor (magicl:from-list '(1.0 2.0 3.0) '(3)))

;; This works
(magicl:.+ float-tensor int-tensor)
;; This is a TYPE-ERROR condition
(magicl:.+ int-tensor float-tensor)

A solution would be to coerce/round/cast one of the arguments, but which one, and when?

Take an example of elementwise sum and the cases of 0.5 + 1 being stored in an int32-tensor. Depending on where, say, the round function is applied the first sum could be

(+ (round 0.5) 1)
;; 1
(round (+ 0.5 1))
;; 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions