// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #include "contrib_ops/cpu/element_wise_ops.h" #include "core/framework/math.h" #include "core/providers/cpu/math/element_wise_ops.h" namespace onnxruntime { namespace contrib { ONNX_CPU_OPERATOR_KERNEL( Affine, 1, KernelDefBuilder().TypeConstraint("T", DataTypeImpl::GetTensorType()), Affine); template <> Status Affine::Compute(OpKernelContext* ctx) const { auto& X = *ctx->Input(0); auto& Y = *ctx->Output(0, X.Shape()); MakeEigenArrayMap(Y) = alpha_ * MakeEigenArrayMap(X) + beta_; return Status::OK(); } ONNX_CPU_OPERATOR_KERNEL( Scale, 1, KernelDefBuilder().TypeConstraint("T", DataTypeImpl::GetTensorType()), Scale); template <> Status Scale::Compute(OpKernelContext* ctx) const { auto& X = *ctx->Input(0); auto& Y = *ctx->Output(0, X.Shape()); EigenMap(Y) = scale_ * EigenMap(X); return Status::OK(); } } // namespace contrib } // namespace onnxruntime