CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
118 lines
3.8 KiB
C++
118 lines
3.8 KiB
C++
// Copyright Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#pragma once
|
|
|
|
#include <rocRoller/Expression.hpp>
|
|
#include <rocRoller/Operations/CommandArgument_fwd.hpp>
|
|
|
|
namespace rocRoller::Expression::EvaluateDetail
|
|
{
|
|
template <typename T>
|
|
concept CIntegral = std::integral<T> && !std::same_as<bool, T>;
|
|
|
|
template <typename T>
|
|
concept isFP32 = std::same_as<float, T>;
|
|
|
|
/**
|
|
* Visitor for a specific Operation expression. Performs that
|
|
* specific Operation (Add, subtract, etc). Does not walk the
|
|
* expression tree.
|
|
*/
|
|
template <typename T, DataType DESTTYPE = DataType::None>
|
|
struct OperationEvaluatorVisitor
|
|
{
|
|
};
|
|
|
|
/**
|
|
* Visitor for an Expression. Walks the expression tree,
|
|
* calling the OperationEvaluatorVisitor to perform actual
|
|
* operations.
|
|
*/
|
|
struct EvaluateVisitor;
|
|
|
|
/**
|
|
* Is satisfied if the unary operation associated with TheEvaluator can be
|
|
* applied to ARG.
|
|
* e.g. TheEvaluator == OperationEvaluatorVisitor<Not>, Arg -> bool
|
|
*
|
|
*
|
|
* @tparam TheEvaluator Specialization of OperationEvaluatorVisitor class
|
|
* for a specific operation
|
|
* @tparam ARG
|
|
*/
|
|
template <typename TheEvaluator, typename ARG>
|
|
concept CCanEvaluateUnary = requires(TheEvaluator ev, ARG arg)
|
|
{
|
|
requires CCommandArgumentValue<ARG>;
|
|
|
|
{
|
|
ev.evaluate(arg)
|
|
} -> CCommandArgumentValue;
|
|
};
|
|
|
|
/**
|
|
* Is satisfied if the binary operation associated with TheEvaluator can be
|
|
* applied to LHS and RHS.
|
|
* e.g. TheEvaluator == OperationEvaluatorVisitor<Add>, LHS -> int, RHS -> int
|
|
*
|
|
* Note that this depends on evaluate() not being defined for invalid pairs of
|
|
* types, thus the use of e.g. `CCanAdd` below.
|
|
*
|
|
* @tparam TheEvaluator Specialization of OperationEvaluatorVisitor class
|
|
* for a specific operation
|
|
* @tparam LHS
|
|
* @tparam RHS
|
|
*/
|
|
template <typename TheEvaluator, typename LHS, typename RHS>
|
|
concept CCanEvaluateBinary = requires(TheEvaluator ev, LHS lhs, RHS rhs)
|
|
{
|
|
requires CCommandArgumentValue<LHS>;
|
|
requires CCommandArgumentValue<RHS>;
|
|
|
|
{
|
|
ev.evaluate(lhs, rhs)
|
|
} -> CCommandArgumentValue;
|
|
};
|
|
|
|
template <typename TheEvaluator, typename LHS, typename R1HS, typename R2HS>
|
|
concept CCanEvaluateTernary = requires(TheEvaluator ev, LHS lhs, R1HS r1hs, R2HS r2hs)
|
|
{
|
|
requires CCommandArgumentValue<LHS>;
|
|
requires CCommandArgumentValue<R1HS>;
|
|
requires CCommandArgumentValue<R2HS>;
|
|
|
|
{
|
|
ev.evaluate(lhs, r1hs, r2hs)
|
|
} -> CCommandArgumentValue;
|
|
};
|
|
|
|
template <CUnary T>
|
|
CommandArgumentValue evaluateOp(T const& op, CommandArgumentValue const& arg);
|
|
|
|
template <CBinary T>
|
|
CommandArgumentValue
|
|
evaluateOp(T const& op, CommandArgumentValue const& lhs, CommandArgumentValue const& rhs);
|
|
|
|
template <CTernary T>
|
|
CommandArgumentValue evaluateOp(T const& op,
|
|
CommandArgumentValue const& lhs,
|
|
CommandArgumentValue const& r1hs,
|
|
CommandArgumentValue const& r2hs);
|
|
|
|
template <CCommandArgumentValue T>
|
|
void assertNonNullPointer(T const& val)
|
|
{
|
|
if constexpr(std::is_pointer<T>::value)
|
|
{
|
|
AssertFatal(val, "Can't offset from nullptr!");
|
|
}
|
|
}
|
|
|
|
CommandArgumentValue reinterpretTruncateValue(CommandArgumentValue const& value,
|
|
DataType targetDataType,
|
|
std::endian endianness);
|
|
}
|
|
|
|
#include <rocRoller/Expression_impl.hpp>
|