// Copyright (c) Advanced Micro Devices, Inc., or its affiliates. // SPDX-License-Identifier: MIT #pragma once #include "ck_tile/core.hpp" #include "ck_tile/host/host_tensor.hpp" #include namespace ck_tile { template CK_TILE_HOST void reference_unary_elementwise(const HostTensor& a, HostTensor& b, ElementOp element_op) { // TODO: imeplement gpu version reference function auto f = [&](auto i) { auto v_a = type_convert(a.mData[i]); auto v_b = element_op(v_a); b.mData[i] = ck_tile::type_convert(v_b); }; make_ParallelTensorFunctor(f, b.get_element_space_size())(std::thread::hardware_concurrency()); } template CK_TILE_HOST void reference_binary_elementwise(const HostTensor& a, const HostTensor& b, HostTensor& c, ElementOp element_op) { // TODO: imeplement gpu version reference function auto f = [&](auto i) { auto v_a = type_convert(a.mData[i]); auto v_b = type_convert(b.mData[i]); auto v_c = element_op(v_a, v_b); c.mData[i] = ck_tile::type_convert(v_c); }; make_ParallelTensorFunctor(f, c.get_element_space_size())(std::thread::hardware_concurrency()); } } // namespace ck_tile