SShapeEstuary
Product

Product features · Tensor broadcast shapes

01

Infer a shared tensor shape by comparing trailing dimensions and expanding unit axes.

01

Connection

Base URL, credentials and a reachable server.

02

Selection

A model available through the configured endpoint.

03

Capabilities

Context limits and tool support are determined by the model and server.

Tensor broadcast shapes

● ● ●ShapeEstuary●
A concrete starting point · Tensor broadcast shapes ×
from itertools import zip_longest

def broadcast_shape(a, b):
    a, b = tuple(a), tuple(b)
    if any(type(d) is not int or d < 0 for d in a + b):
        raise ValueError("dimension.invalid")
    result = []
    for left, right in zip_longest(reversed(a), reversed(b), fillvalue=1):
        if left == right or right == 1:
            result.append(left)
        elif left == 1:
            result.append(right)
        else:
            raise ValueError("shape.incompatible")
    return tuple(reversed(result))
✳Infer a shared tensor shape by comparing trailing dimensions and expanding unit axes.
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗