interpreter.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:tsfc 作者: firedrakeproject 项目源码 文件源码
def _evaluate_concatenate(e, self):
    """Concatenate nodes flatten and concatenate shapes."""
    ops = [self(o) for o in e.children]
    fids = tuple(OrderedDict.fromkeys(itertools.chain(*(o.fids for o in ops))))
    fshape = tuple(i.extent for i in fids)
    arrs = []
    for o in ops:
        # Create temporary with correct shape
        arr = numpy.empty(fshape + o.shape)
        # Broadcast for extra free indices
        arr[:] = o.broadcast(fids)
        # Flatten shape
        arr = arr.reshape(arr.shape[:arr.ndim-len(o.shape)] + (-1,))
        arrs.append(arr)
    arrs = numpy.concatenate(arrs, axis=-1)
    return Result(arrs, fids)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号