drhagen / tensora

Sparse/dense tensor library for Python
http://tensora.drhagen.com/
MIT License
9 stars 2 forks source link

Support scalars appropriately #33

Closed drhagen closed 10 months ago

drhagen commented 11 months ago

Scalars in tensor expressions should be interpreted as floats. The Tensora compiler could generate code that accepts doubles, but TACO will not. We could shim the TACO code so that evaluate_taco still accepts floats, but that sounds like a source of ambiguity.

Here are the steps needed to implement this:

  1. Make generate_c_code_tensora generate C code that takes doubles
  2. Make generate_c_code_taco fail on any scalar format
  3. Make PureTensorMethod.__call__ handle inputs and outputs that are scalar arguments. Should allow int and float as inputs. Should return a Python float as an output.
drhagen commented 10 months ago

Ugh, this complicates the code a lot for very little benefit. I can see why TACO never properly supported it. The porcelain functions can still convert all floats to order-0 tensors and return floats when appropriate (e.g. x @ y).