Skip to content

The base and exponent of pow() should be allowed to have different data types #939

Description

@miaobin

Summary

pow() currently inherits the element-wise binary contract that requires both inputs to share the same data type. Unlike add/sub/mul — where both operands are the same kind of quantity — a power's base and exponent are conceptually distinct and are commonly different types (e.g. an integer or float32 exponent applied to a float16/int base). The same-type requirement forces redundant casts and rejects valid models.

Current behavior

We are currently encountering the following situation with the model (pow(int64_base, float32_exponent) is rejected at
graph-build time):

Image

Backends status

  • ONNX Pow-15 constrains X (and output) and Y with independent type sets — they need not match. Output type follows X (the base), consistent with WebNN's "output = a's type".
  • TFLite tfl.pow and CoreML MIL elementwise_binary.pow likewise take base/exponent as separate operands.

Proposal and questions

  • Give pow() its own tensor limits
    • Should the b (exponent) be restricted to a small set (e.g. float32 + uint32, TFLite only support tensor of 32-bit float or 32-bit signless integer values), or allowed broadly?
    • Should we accept the output based on the input a (with integer truncation)?
  • Give pow() its own data-type validation

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