コード例 #1
0
 def _broadcast(x, dims):
     etype = ir.RankedTensorType(x.type).element_type
     return mhlo.BroadcastOp(ir.RankedTensorType(dims, etype), x,
                             mlir.dense_int_elements(dims))
コード例 #2
0
def full_like_aval(value, aval: core.ShapedArray) -> ir.Value:
    """Returns an IR constant shaped full of `value` shaped like `aval`."""
    zero = ir_constant(np.array(value, aval.dtype))
    return mhlo.BroadcastOp(aval_to_ir_type(aval), zero,
                            dense_int_elements(aval.shape)).result
コード例 #3
0
 def _broadcast(x, dims):
     return mhlo.BroadcastOp(x, mlir.dense_int_elements(dims))