Register MLIR generated kernel for Complex.
PiperOrigin-RevId: 351954046 Change-Id: I9df849dc53fae72fbdb6dc56d82c0b36a2ded230
This commit is contained in:
parent
7180803d3a
commit
7c8538cbd7
@ -928,7 +928,7 @@ func @broadcast_to(%arg0: tensor<16xf32>) -> tensor<16x16x16x16xf32> {
|
|||||||
|
|
||||||
// CHECK-LABEL: func @complex
|
// CHECK-LABEL: func @complex
|
||||||
func @complex(%arg0: tensor<3xf32>, %arg1: tensor<3xf32>) -> tensor<3xcomplex<f32>> {
|
func @complex(%arg0: tensor<3xf32>, %arg1: tensor<3xf32>) -> tensor<3xcomplex<f32>> {
|
||||||
// CHECK: "mhlo.complex"
|
// CHECK: chlo.broadcast_complex
|
||||||
%1 = "tf.Complex"(%arg0, %arg1) : (tensor<3xf32>, tensor<3xf32>) -> tensor<3xcomplex<f32>>
|
%1 = "tf.Complex"(%arg0, %arg1) : (tensor<3xf32>, tensor<3xf32>) -> tensor<3xcomplex<f32>>
|
||||||
return %1 : tensor<3xcomplex<f32>>
|
return %1 : tensor<3xcomplex<f32>>
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,7 @@ class DirectBinaryPat<Op FromOp, Op ToOp>
|
|||||||
|
|
||||||
foreach fromToBinPair = [[TF_AddV2Op, HLOClient_BroadcastAddOp],
|
foreach fromToBinPair = [[TF_AddV2Op, HLOClient_BroadcastAddOp],
|
||||||
[TF_Atan2Op, HLOClient_BroadcastAtan2Op],
|
[TF_Atan2Op, HLOClient_BroadcastAtan2Op],
|
||||||
|
[TF_ComplexOp, HLOClient_BroadcastComplexOp],
|
||||||
[TF_DivOp, HLOClient_BroadcastDivOp],
|
[TF_DivOp, HLOClient_BroadcastDivOp],
|
||||||
[TF_LeftShiftOp, HLOClient_BroadcastShiftLeftOp],
|
[TF_LeftShiftOp, HLOClient_BroadcastShiftLeftOp],
|
||||||
[TF_MaximumOp, HLOClient_BroadcastMaxOp],
|
[TF_MaximumOp, HLOClient_BroadcastMaxOp],
|
||||||
@ -111,8 +112,6 @@ def LowerRightShiftSigned :
|
|||||||
// TODO(hinsu): Lower unsigned types to HLO_ShiftRightLogical once the HLO op
|
// TODO(hinsu): Lower unsigned types to HLO_ShiftRightLogical once the HLO op
|
||||||
// supports unsigned integers.
|
// supports unsigned integers.
|
||||||
|
|
||||||
def : Pat<(TF_ComplexOp $r, $i), (HLO_ComplexOp $r, $i)>;
|
|
||||||
|
|
||||||
// Performs a substitution of FloorDiv, pseudo code below:
|
// Performs a substitution of FloorDiv, pseudo code below:
|
||||||
//
|
//
|
||||||
// return floor(div(x, y))
|
// return floor(div(x, y))
|
||||||
|
@ -27,9 +27,12 @@ REGISTER_COMPLEX(CPU, float, complex64);
|
|||||||
REGISTER_COMPLEX(CPU, double, complex128);
|
REGISTER_COMPLEX(CPU, double, complex128);
|
||||||
|
|
||||||
#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM
|
#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM
|
||||||
|
#if !defined(MLIR_GENERATED_GPU_KERNELS_ENABLED) || \
|
||||||
|
!defined(MLIR_GENERATED_EXPERIMENTAL_GPU_KERNELS_ENABLED)
|
||||||
REGISTER_COMPLEX(GPU, float, complex64);
|
REGISTER_COMPLEX(GPU, float, complex64);
|
||||||
REGISTER_COMPLEX(GPU, double, complex128);
|
REGISTER_COMPLEX(GPU, double, complex128);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef REGISTER_COMPLEX
|
#undef REGISTER_COMPLEX
|
||||||
} // namespace tensorflow
|
} // namespace tensorflow
|
||||||
|
@ -50,6 +50,7 @@ filegroup(
|
|||||||
"gpu_op_asin.cc",
|
"gpu_op_asin.cc",
|
||||||
"gpu_op_atan.cc",
|
"gpu_op_atan.cc",
|
||||||
"gpu_op_ceil.cc",
|
"gpu_op_ceil.cc",
|
||||||
|
"gpu_op_complex.cc",
|
||||||
"gpu_op_conj.cc",
|
"gpu_op_conj.cc",
|
||||||
"gpu_op_cos.cc",
|
"gpu_op_cos.cc",
|
||||||
"gpu_op_exp.cc",
|
"gpu_op_exp.cc",
|
||||||
@ -112,6 +113,7 @@ tf_kernel_library(
|
|||||||
":asin_kernels",
|
":asin_kernels",
|
||||||
":atan_kernels",
|
":atan_kernels",
|
||||||
":ceil_kernels",
|
":ceil_kernels",
|
||||||
|
":complex_kernels",
|
||||||
":conj_kernels",
|
":conj_kernels",
|
||||||
":cos_kernels",
|
":cos_kernels",
|
||||||
":exp_kernels",
|
":exp_kernels",
|
||||||
|
@ -469,6 +469,25 @@ GENERATE_DEFAULT_TESTS(BitwiseXor,
|
|||||||
GENERATE_DEFAULT_TESTS(BitwiseXor,
|
GENERATE_DEFAULT_TESTS(BitwiseXor,
|
||||||
/*test_name=*/Int64, int64, int64, baseline_bitwise_xor)
|
/*test_name=*/Int64, int64, int64, baseline_bitwise_xor)
|
||||||
|
|
||||||
|
/// Test `tf.Complex`.
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::complex<T> baseline_complex(T lhs, T rhs) {
|
||||||
|
return std::complex<T>(lhs, rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
GENERATE_DEFAULT_TESTS_2(
|
||||||
|
Complex,
|
||||||
|
/*test_name=*/C64, float, float, std::complex<float>, std::complex<float>,
|
||||||
|
test::DefaultInput<float>(), test::DefaultInput<float>(), baseline_complex,
|
||||||
|
test::GpuOpsTestConfig().ExpectStrictlyEqual().AddTout())
|
||||||
|
GENERATE_DEFAULT_TESTS_2(
|
||||||
|
Complex,
|
||||||
|
/*test_name=*/C128, double, double, std::complex<double>,
|
||||||
|
std::complex<double>, test::DefaultInput<double>(),
|
||||||
|
test::DefaultInput<double>(), baseline_complex,
|
||||||
|
test::GpuOpsTestConfig().ExpectStrictlyEqual().AddTout())
|
||||||
|
|
||||||
/// Test `tf.Div`.
|
/// Test `tf.Div`.
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -20,10 +20,10 @@ limitations under the License.
|
|||||||
|
|
||||||
namespace tensorflow {
|
namespace tensorflow {
|
||||||
|
|
||||||
GENERATE_UNARY_KERNEL2(Complex, f32, DT_COMPLEX64, std::complex<float>, float);
|
GENERATE_BINARY_KERNEL2(Complex, f32, DT_COMPLEX64, std::complex<float>, float);
|
||||||
REGISTER_COMPLEX_KERNEL(Complex, f32, std::complex<float>, float);
|
REGISTER_COMPLEX_KERNEL(Complex, f32, std::complex<float>, float);
|
||||||
GENERATE_UNARY_KERNEL2(Complex, f64, DT_COMPLEX128, std::complex<double>,
|
GENERATE_BINARY_KERNEL2(Complex, f64, DT_COMPLEX128, std::complex<double>,
|
||||||
double);
|
double);
|
||||||
REGISTER_COMPLEX_KERNEL(Complex, f64, std::complex<double>, double);
|
REGISTER_COMPLEX_KERNEL(Complex, f64, std::complex<double>, double);
|
||||||
|
|
||||||
} // namespace tensorflow
|
} // namespace tensorflow
|
||||||
|
Loading…
x
Reference in New Issue
Block a user