// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #include "complex_mul_impl.h" namespace onnxruntime { namespace contrib { namespace cuda { #define REGISTER_KERNEL_TYPED(T) \ ONNX_OPERATOR_TYPED_KERNEL_EX( \ ComplexMul, \ kMSDomain, \ 1, \ T, \ kCudaExecutionProvider, \ (*KernelDefBuilder::Create()) \ .TypeConstraint("T", DataTypeImpl::GetTensorType()), \ ComplexMul); \ ONNX_OPERATOR_TYPED_KERNEL_EX( \ ComplexMulConj, \ kMSDomain, \ 1, \ T, \ kCudaExecutionProvider, \ (*KernelDefBuilder::Create()) \ .TypeConstraint("T", DataTypeImpl::GetTensorType()), \ ComplexMul); REGISTER_KERNEL_TYPED(float) REGISTER_KERNEL_TYPED(MLFloat16) template Status ComplexMul::ComputeInternal(OpKernelContext* context) const { for (int index = 0; index < context->InputCount(); ++index) { const Tensor* input = context->Input(index); TensorShape shape = input->Shape(); int64_t last_dimension = shape[shape.NumDimensions() - 1]; ORT_ENFORCE(last_dimension == 2, "The input_", index, " last dimension is supposed to be 2, but get ", last_dimension); } BinaryElementwisePreparation prepare; ORT_RETURN_IF_ERROR(Prepare(context, &prepare)); ComplexMul_Impl::MappedType>( Stream(context), prepare.output_rank_or_simple_broadcast, &prepare.lhs_padded_strides, reinterpret_cast::MappedType*>(prepare.lhs_tensor->Data()), &prepare.rhs_padded_strides, reinterpret_cast::MappedType*>(prepare.rhs_tensor->Data()), &prepare.fdm_output_strides, prepare.fdm_H, prepare.fdm_C, reinterpret_cast::MappedType*>(prepare.output_tensor->MutableData()), prepare.output_tensor->Shape().Size(), prepare.lhs_tensor->Shape().Size(), prepare.rhs_tensor->Shape().Size(), is_conj); return Status::OK(); } } // namespace cuda } // namespace contrib } // namespace onnxruntime