Skip to content

Misleading LazyTensor internal dimension management #425

@bcharlier

Description

@bcharlier

Internal dimension equals to 1 does not appear in the LazyTensor.shape attribute

import numpy as np
from pykeops.numpy import LazyTensor

# work as expected
print(LazyTensor(np.ones((1,10, 2))))
# KeOps LazyTensor
#    formula: Var(0,2,1)
#    shape: (1, 10, 2)

# strange...
print(LazyTensor(np.ones((1,10, 1))))
# KeOps LazyTensor
#   formula: Var(0,1,1)
#   shape: (1, 10)

A better choice should be shape: (1, 10, 1). It yields to strange expression :

print(LazyTensor(np.ones((1,10, 2))).sum(-1).sum(-1))
# KeOps LazyTensor
#    formula: Sum(Sum(Var(0,2,1)))
#    shape: (1, 10)

Not coherent with

print(LazyTensor(np.ones((1,10, 2))).sum(-1).sum(1).shape)
# (1, 1)

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