Exemple #1
0
def transform_sum(expr):
    x = only_arg(expr)
    m, n = dims(x)

    if not expr.has_axis:
        return expression.linear_map(linear_map.sum(m, n), transform_expr(x))

    if expr.axis == 0:
        return expression.linear_map(linear_map.sum_left(m, n), transform_expr(x))

    if expr.axis == 1:
        return expression.linear_map(linear_map.sum_right(m, n), transform_expr(x))

    raise TransformError("unknown axis attribute", expr)
Exemple #2
0
def transform_sum(expr):
    x = only_arg(expr)
    m, n = dims(x)

    if not expr.has_axis:
        return expression.linear_map(linear_map.sum(m, n), transform_expr(x))

    if expr.axis == 0:
        return expression.linear_map(linear_map.sum_left(m, n),
                                     transform_expr(x))

    if expr.axis == 1:
        return expression.linear_map(linear_map.sum_right(m, n),
                                     transform_expr(x))

    raise TransformError("unknown axis attribute", expr)
Exemple #3
0
def transform_sum(expr):
    return expression.linear_map(
        linear_map.sum(dim(only_arg(expr))),
        transform_expr(only_arg(expr)))