Skip to content

Propagate efficient NDArray and staticTensor scalar+tensor operations for dynamicTensor #41

Open
@Iainmon

Description

@Iainmon

Propagate efficient ndarray and staticTensor scalar+tensor operations such as

// lib/NDArray.chpl
operator +(a: ndarray(?rank,?eltType),c: ?scalarType): ndarray(rank,eltType)
        where isNumericType(scalarType) do
    return ndarray.scalarMapOp("+",a,c);

and

// lib/StaticTensor.chpl
operator +(a: staticTensor(?rank,?eltType),c: ?scalarType): staticTensor(rank,eltType)
        where isNumericType(scalarType) do
    return staticTensor.scalarMapOp("+",a,c : eltType);

up into the dynamicTensor world. Right now these operations are implemented as

// lib/DynamicTensor.chpl
operator +(a: dynamicTensor(?eltType),c: ?scalarType): dynamicTensor(eltType) 
        where isNumericType(scalarType) {
    for param rank in 1..maxRank {
        if a.checkRank(rank) {
            return (a.forceRank(rank) + c).eraseRank();
        }
    }
    halt("Could not determine rank in dynamicTensor + " + scalarType:string + ".");
}

Which is not the most efficient implementation, and should use the versions defined in lib/NDArray.chpl and lib/StaticTensor.chpl.

The solution is trivial, as the definitions in lib/DynamicTensor.chpl, which should use the definitions in lib/NDArray.chpl. But there should be tests verifying this relationship.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions